Index  Up  <<  >>  


More on UPS-style lookup

The UPS-style lookup uses two files for its purposes, both of which need to be in a format like UPS distributes for US shippers.

The zone file is a file that is usually specific to the originating location. For US shippers shipping to US locations, it is named for the first three digits of the originating zip code with a CSV extenstion -- for example, 450.csv.

It has a format similar to:

    low - high, zone,zone,zone,zone

The low entry is the low bound of the geographic location -- high is the high bound. (By geographic location we mean zip code.) If the first digits of the zip code, compared alphanumerically, fall between the low and high values, that zone is used as the column name for a lookup in the rate database. The weight is used as the row key.

The first operative row of the zone file (one without leading quotes) is used to determine the zone column name. In the US, it looks something like

Dest. ZIP,Ground,3 Day Select,2nd Day Air,2nd Day Air A.M.,Next Day Air Saver,Next Day Air

MiniVend strips all non-alpha characters and comes up with:

DestZIP,Ground,3DaySelect,2ndDayAir,2ndDayAirAM,NextDayAirSaver,NextDayAir

Therefore, the zone column (shipping type) that you would use use for UPS ground would be ``Ground'', and that is what the database should be named. To support the above, you would want a shipping.asc line that reads:

    upsg  UPS Ground  weight  0  150  u Ground [default zip 983]

and a catalog.cfg database callout of:

    Database  Ground  Ground.csv  CSV

You can change these column names as long as they correspond to the identifier of your rate database.

The rate database is a standard MiniVend database. For US shippers, UPS distributes their rates in a fairly standard comma-separated value format, with weight being the first (or key) column and the remainder of the columns corresponding to the zone -- which you obtain from the lookup in the zone file.

To adapt other shipper zone files to MiniVend's lookup, you will need to make it fit the UPS US format. (Most of the UPS international files don't follow the US format). For example, the 1998 Ohio-US to Canada file begins:

    Canada Standard Zone Charts from Ohio
    Locate the zone by cross-refrencing the first three
    characters of the destination Postal Code in the Postal
    Range column.
 
    Postal Range  Zone
    A0A  A9Z      54
    B0A  B9Z      54
    C0A  C9Z      54
    E0A  E9Z      54
    G0A  G0A      51
    G0B  G0L      54
    G0M  G0S      51
    G0T  G0W      54

You need to change it to

 
    Destination,canstnd
    A0A-A9Z, 54
    B0A-B9Z, 54
    C0A-C9Z, 54
    E0A-E9Z, 54
    G0A-G0A, 51
    G0B-G0L, 54
    G0M-G0S, 51
    G0T-G0W, 54

and match it with a canstnd CSV database that looks like

    Weight,51,52,53,54,55,56
    1,7.00,7.05,7.10,11.40,11.45,11.50
    2,7.55,7.65,7.75,11.95,12.05,12.10
    3,8.10,8.15,8.40,12.60,12.70,12.85
    4,8.65,8.70,9.00,13.20,13.30,13.55
    5,9.20,9.25,9.75,13.85,13.85,14.20
    6,9.70,9.85,10.35,14.45,14.50,14.90
    7,10.25,10.40,11.10,15.15,15.15,15.70
    8,10.80,10.95,11.70,15.70,15.75,16.35
    9,11.35,11.55,12.30,16.40,16.45,17.20

and is called out in catalog.cfg with:

    Database canstnd canstnd.csv CSV

With the above, a 4-pound shipment to postal code E5C 4TL would yield a cost of 13.20.


Index  Up  <<  >>