Shipping zone and rate page |
home page JavaScript autoship example cart w/zones pseudo cart w/zones |
* 11 February, 2005. Corrected text to refer to JavaScript
* 10 September, 2004. Added example conversion programs.
The major shipping providers give you charts of shipping zones from your location. The customer enters his ZIP code, a shipping zone is calculated and the weight of the items ordered is used to calculate shipping charges. Here is how you build a shipping zone and rate chart into your PayPal site with JavaScript.
First you go to the service of your choice and get to the proper location, such as USPS Zones. You must really look at the site to see what they have, because it can get really complicated. UPS, USPS and FedEx all have similar things (see attached link-list at the end.)
In the case of USPS you have to enter the first 3 digits of your ZIP code in the target page. From this they generate a list of zones that are distant from your originating ZIP. Save this table because we are gonna use it in a bit.
Now go to charges based on Zones, or RateFold (Notice 123). Now you have the USPS zones, and you have a page that describes shipping of various types to those zones. All you have to do now is construct several tables that describe shipping to the destination zone based on the type of shipping you want to offer your customer.
The charges should be based on weight, but if you have rather uniform items on your site (such as different DVDs) then this works because YOU know weight (how many of them to the pound.)
If you want to follow along with me, I am going to construct a zone chart for ZIP code 81503. First print off the Zone chart (enter 815 and print out the chart you get.) From this data, and the fees from the Domestic Postal Rates page we are going to construct some tables that will calculate real shipping for the continental U. S. for Priority mail.
First, the ZIP table. We are going to construct a table with pairs of entries - ZIP/Zone entries. We do this by entering the first number of ZIP prefix (or ZIP prefix range) followed by the Zone number. Look at the 815 table...
005 7 006 - 067 6 068 - 128 7 129 8 130 - 212 7 214 - 241 7 242 6 ...
Notice that ZIPs 130 to 241 are all Zone 7. This saves us some typing because we only have to enter the first ZIP of a range that yields the same zone...
SetZone ( 5, 7, 6, 6, 68, 7, 129, 8, 130, 7,
242, 6, ... );
Note - do NOT enter numbers with leading zeros (reserved for Octal).
When you build this table one little mistake can ruin everything, so I suggest that you only put 5 pairs of ZIP/Zone data on a line so you can keep track of them. (View the JavaScript file to see how I built it - link in upper-right corner of this page.)
Next we have to build tables of rates for each zone. These tables will not change for different zone charts, and are hard-coded in the JS - one zone table for all rate structures. (That's how it works.)
As coded here, the JS global variables zne, mpp and amt contain the zone and the amount to ship that weight to that zone.
This calculation may be placed into your PayPal pages. After you build your zone table just ask the customer for his ZIP code, and plug in the shipping costs. Of course, you have to lock out PayPal changes for this to work. I am going to build this table into my shopping cart that is based on weight, and expand it up to 70 pounds. Have fun.
Contact me concerning this article at
paypalhelper@aol.com.
Mention USPS Zones in your note.
Individual help starting at $25.00 for simple JS solutions.
Some links to help you with your shipping tables and charges...
* USPS Zones, and Priority rates.
* UPS Zones, and
UPS Rates
* FedEx Zones.
and
FedEx Rates
* DHL Zones.
and
DHL Rates
These tables may also be used to construct shipping charts with the SetSH function. For example, you may not want to construct a complete shipping table for Europe, so you can approximate charges to those countries by building charge tables with the quantity-based shipping charge builder (SetSH).
I was a little surprised to discover that USPS was cheaper than UPS below the 3-9 pound area, depending on distance and UPS fuel charges. Perhaps the best approach is to calculate several different shipping options for the user, display them and let him take his pick.
The total surprise to me was that you could calculate zone tables for any shipper there is (they all supply this information), and support national or international - depends on how much time you want to spend to set up your tables. It can all be done client-side without the need for a server, or e-commerce solution. Remarkable! But, ya gots to know some JavaScript to do it, huh?
NOTE - you must really read these charts! In the case of UPS there are some zones (Hawaii, Alaska, and the Protectorates) that require special attention. The best solution is, probably, to create special zones for their ZIPs (9, 10, 11, etc) and enter them into your tables (both zone and charge.) Any other solution simply misleads people in these ZIP code areas. USPS is subsidized, and it may be cheaper to ship to those areas that way.
I have built some programs that automatically extract both rate and zone information from the major shipping firms, and put it into a format almost ready for my code. The way it works is to capture the data from the shipping companies and paste it into the conversion routines, hit a "convert" button, and then copy the data and paste it into cart.js (of my cart) - it's a little complicated, but so many people have asked for it that I felt compelled. (It's what I use, but you have to know what you are doing!)
You may have to adjust these a bit depending on how you extract the data - but they give you a guide. I use these because I extract the data the same way every time, and I know how I do it. A one-time-shot for your site may not allow you to get too familiar with these methods. I provide them in the hope that they will help...
Fed Rates