HOW TO: Manually create shipping table rates
Table rates are calculated based on match type system gathered from either a order record or a quote record. Let’s start with an example, and then I’ll explain a little bit more in depth.
You can create records in the database using this code.
INSERT INTO shipping_tablerate ( website_id, dest_country_id, dest_region_id, dest_zip, condition_name, condition_value, price, cost ) VALUES ( 1, 'CA', 0, '', 'package_qty', '1.0000', '4.0000', '1.0000' )
- website_id: website with ID 1,
- dest_country_id: the destination country IDs,
- dest_region_id: The region Ids - corrspond to the regions found in the database table directory_country_region. A value of 0 means match all.
- dest_zip: This is can be an arbitrary number. This field performs the final match against the order. It corresponds to the postcode field in the order/quote. A value of 0 means match all.
- condition_name: This can be either ‘package_weight’,’package_value’, or ‘package_qty’. This field determines whether or not the table rate will match the quote/order.
- condition_value: This is can be an arbitrary number. It is used in conjuction with condition_name to determine a match.
- price: This is can be an arbitrary number. This will be the displayed cost to the enduser (customer).
- cost: This is can be an arbitrary number. This will be the displayed cost to the admin (accountant).
As previously mentioned, table rates are calculated based from an order/quote record. If all of the conditions are met, then the table rate will be displayed. In the example code provided above, if an order can through the system, the example database record would match it IF, and only IF, it was placed on the website with ID 1 (website_id), that is being shipping to Canada (dest_country_id), in any province in Canada (dest_region_id), to any postal code (dest_zip), that has at least one item in the quote. A price of $4.00 is displayed to the customer, and a price of $1.00 is displayed to the accountant.
All of the destination country IDs can be found on this page: http://www.iso.org/iso/english_country_names_and_code_elements
Quotes or Orders matching a condition_value of 0 (zero), will not return a table rate. To use “free” rates, you can either use the “free shipping” method included in the shipping rates, or you can edit the source code to return the nil item.