6.4. How Shipping is Calculated

  1. The base code is selected by reading the value of mv_shipmode in the user session. If it has not been explicitly set, either by means of the DefaultShipping directive or by setting the variable on a form (or in an order profile), it will be default.
    The mv_shipmode must be in the character class [A-Za-z0-9_]. If there are spaces, commas, or nulls in the value, they will be read as multiple shipping modes.
  2. The modes are selected from the d
      The criterion field is found. If it is quantity, it is the total quantity of items on the order form. If it is any other name, the criterion is calculated by multiplying the return value from the product database field for each item in the shopping cart, multiplied by its quantity. If the lookup fails due to the column or row not existing, a zero cost will be returned and an error is sent to the catalog error log. If a number is returned from an Interchange tag, that number is used directly.
      Entries in the shipping database that begin with the same string as the shipping mode are examined. If none is found, a zero cost is returned and an error is sent to the catalog error log.


Note: The same mode name may be used for all lines in the same group, but the first one will contain the main criteria.

  1. The value of the accumulated criteria is examined. If it falls within the minimum and maximum, the cost is applied.
  2. If the cost is fixed, it is simply added.
  3. If the cost field begins with an x, the cost is multiplied by the accumulated criterion, i.e., price, weight, etc.
  4. If the cost field begins with f, the formula following is applied. Use @@TOTAL@@ as the value of the accumulated criterion.
  5. If the cost field begins with u or a single letter from A-Z, a UPS-style lookup is done.
  6. If the cost field begins with s, a Perl subroutine call is made.
  7. If the cost field begins with e, zero cost is returned and an error placed in the session ship_message field, available as [data session ship_message].

Here is an example shipping file using all of the methods of determining shipping cost.


Note: The columns are lined up for reading convenience. The actual entries should have one tab between fields.

global Option   n/a               0   0      g PriceDivide

rpsg   RPS      quantity          0   0      R RPS products/rps.csv
rpsg   RPS      quantity          0   5      7.00
rpsg   RPS      quantity          6   10     10.00
rpsg   RPS      quantity          11  150    x .95

usps   US Post  price             0   0      0
usps   US Post  price             0   50     f 7 + (1 * @@TOTAL@@ / 10)
usps   US Post  price             50  100    f 12 + (.90 * @@TOTAL@@ / 10)
usps   US Post  price             100 99999  f @@TOTAL@@ * .05

upsg   UPS      weight [value state]  0   0    e Nothing to ship.
upsg   UPS      AK HI             0   150    u upsg [default zip 980] 12.00 round
upsg   UPS                        0   150    u Ground [default zip 980] 2.00 round
upsg   UPS                        150 9999   e @@TOTAL@@ lb too heavy for UPS

upsca  UPS/CA   weight            0   0      c C UPS_Canada products/can.csv
upsca  UPS/CA   weight            -1   -1    o PriceDivide=0
upsca  UPS/CA   weight            0   150    C upsca [default zip A7G] 5.00
upsca  UPS/CA   weight            150 99999  e @@TOTAL@@ lb too heavy for UPS

global

rpsg

usps

upsg

            1. Weight
            2. The zip/postal code of the recipient of which only
               the first three digits are used.
            3. A fixed amount to add to the cost found in the UPS
               tables (use 0 as a placeholder if specifying roundup)
            4. If set to 'round,' will round the cost up to the next
               integer monetary unit.
            UPSZoneFile  products/450.csv
            Database  Ground  Ground.csv  CSV
            @@COST@@  is replaced with whatever the UPS lookup returned
            @@GEO@@   is replaced with the zip (or other geo code)
            @@ADDER@@ is replaced with the defined adder
            @@TYPE@@  is replaced with the UPS shipping type
            @@TOTAL@@ is replaced with the total weight

upsca

            c X name file* length* multiplier*
            c U UPS products/450.csv 3 1