U.S. Postal Service - Table Based. Now with Auto Update!

Contrib type: 
Module
Status: 
Uploaded for testing
Latest version: 
1.1

Downloads

Compatibility: 
Ubercart 1.x

Intro
This module has internal rate tables to calculate shipping based on the zip code and weight of the package. The rates are based on zones, so the module will calculate the zone based on the zip code of the customer. There are many advantages using this on-site table method verses an online XML api including but not limiting to: 100% reliable even if the USPS servers are down, instant quotes instead of waiting for a response from the other server, and the overall coding is more mature and has less things to go wrong.

What's new in 1.1
The first release (1.0) of this module relied on manually downloading a ".rate" file and dropping it into your /modules/ubercart/uc_usps_table, and then going in the admin panel to click "import rates" to finally get the rates imported. The store owner would periodically have to check the shipping panel to see if a new rate file is out yet. It has been quoted that this is "the only drawback" to this method verses the online api method.

Well those days are over my friends. I have spent many hours developing a solution to this problem and have finally come up with it. Since USPS does not have a machine-readable page with the rates listed, I wrote a code to extract the data from the page. The auto-update feature runs off of cron and will read the USPS website to see if there are new rates out. If there are, it will extract the needed values and update your rate table- all while you are sleeping Smiling

[tech talk]There is no need to worry about performance issues when auto-update is on, I have thought about that too. When cron runs it will only download the meta tags instead of retrieving the entire page. If the rates have updated, then it will run the update function and perform the necessary steps.

Also new in 1.1 is the way you retrieve a quote. You no longer have use a zip->zone function then a weight/zone->rate function. The new function uc_usps_table_quote($weight, $zip, $service = NULL) will take care of everything for you. Note the new $service parameter, as of now it is not in use.[/tech talk]

Google Checkout Compatible
This module features Google Checkout compatibility. Online calculators take too long to get a response and Google Checkout will use a default value price for shipping costs. Google Checkout gives a 3-second window for you to calculate shipping and send the prices back, so a table based method is necessary.

Help needed
As I mentioned before I have spent many hours developing this module. Though it may seem simple looking at it now, so does a transistor but look how many years it took to be discovered. I will admit I needed this for my client, but I will also admit that my client could not care less about auto-update or anything else; I could have hard coded this into Ubercart in a fraction of the time. All I ask in return is that someone please code in the Ubercart shipping hooks so that this can be used with regular checkout. It would make me extremely happy to see this code get put to good use rather then dying here on the table (a play on words Sticking out tongue) This module also needs the other USPS mail services integrated, I have thoroughly commented my code so it should be fairly easy. If you need any help I would be happy to lend a hand.

Installation
Install and enable this module like any ordinary Ubercart module.

To import rate definitions either wait for cron to run or run it manually.

The zone charts with USPS are dynamic and just depend on the origin zip code so everyone will have different zone definitions. Note that the zones apparently have an effective date, though I don't think the zones change, only new zips are added periodically so it is not a big deal. To install the zone definitions for your origin follow these instructions:

  1. Head over to the USPS Zone Charts and insert your origin zip code: http://postcalc.usps.gov/Zonecharts/
  2. Click "Get Zone Chart" and then "Print Zone Chart" (this will make a printable html page)
  3. Save the page and rename the file to "zip.html"
  4. Drop your zip.html file into your /modules/ubercart/uc_usps_table folder
  5. Browse to /admin/store/settings/quotes/usps_table/zimport and click "Import Zips"

Enjoy!

Related threads: (This will need to be recovered from the Google Cache if still necessary.)
Table based USPS shipping calculator: Finished.

PreviewAttachmentSize
uc_usps_table.tar.gz7.54 KB
zmove's picture
Offline
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.Internationalizationizer
Joined: 08/13/2007
Juice: 1195
Create by country and weight shipping cost ?

Hi,

If I understand well, this module calculate the shipping cost depending on the weight and the postal code (in USA) of the package.

Why not extend the functionnality by, instead of choose zone, choose country which could be very usefull for export shop.

Instead of compare the zip code with zone, it could compare the name of the country and each store owner could put in the site-table each price he want to make for this country.

The way you describe your contribution believe to me that it's pretty easy to add this functionnality.

And why not combine both, store owner could make different prices depending on weight, country AND/OR zone. And we could have the ultimate zone-table shipping cost calculation e-commerce owner dream. (like the excellent table-country calculation of osCommerce)

Am I wrong ?

druru's picture
Offline
Brain Stormer
Joined: 08/08/2007
Juice: 228
Re: Create by country and weight shipping cost ?

if it's so easy, why not extend it yourself Eye-wink. the author of the module probably only needs zones.

it sounds like you have a good handle on what you want to do. just do it!

2 cents

zmove's picture
Offline
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.Internationalizationizer
Joined: 08/13/2007
Juice: 1195
Re: Re: Create by country and weight shipping cost ?

I don't say it's easy because a module of this level cannot be easy to implement (for my developper skill especially). But the way his behavior is described, it seems pretty easy to extend his functionnality.

I need this functionnality so I will put my head on the code, but as I say, my developper skill are not uber (^^) and I will certainly need help to do that.

But I think the contribution developper is the best people for modifying his contrib and he could maybe do that in 1 hour when I will need 15 day to do that.

That's the reason of my post, I didn't say "I need that so develop it", I only submit an idea because the module developper maybe don't think about other countries (because he only sell on USA) and maybe it's easy (for him) to implement.

If I successfully add this functionnality, be sure that I will post my contribution for all Eye-wink

druru's picture
Offline
Brain Stormer
Joined: 08/08/2007
Juice: 228
Re: U.S. Postal Service - Table Based. Now with Auto Update!

If theOverClocked is still out there... or for anybody else who knows the answers to these questions.

I finally got around to using this usps table module with a fresh install of uc 7c.

I'm having trouble getting a rate import to occur. i followed your directions above and imported the zip code file fine.

However, in order to get the rates, I tried running cron and i don't see any file to import.. I then went and reread the instructions again and it's possible that cron actually updated a rate table and i don't need to import a file?

Is that correct? I guess i'm wondering if a rate file needs to be imported at all if you run cron.php?

Also, after rereading this page again, it looks to me like this module might actually NOT be complete or actually serve shipping rates as it is. There is mention about hooks being needed for shipping. Is that correct? Am i to assume that enabling this module won't actually allow for the zone based shipping?

If this module is NOT fully functional.. I'd like to draw attention to the uc guys (lyle) that understand the shipping hooks to actually try and provide the interface to this module and get it working. sounds like OverClocked did the hard part (i'm assuming patching the hooks wouldn't be too hard if you know what they are) and his functionality seems too practical and good to let it just sit here without being used. His code eliminates the need for most stores to guesstimate flat rate or weight and doesn't require usps accounts. In that sense, it provides accurate weight/zone based rates without the need for usps accounts and live access to the usps server.

A win win imho.

Anybody?

dru

FYI, i'm going to post this in on the module page as well in case you stop by there or someone else does.

druru's picture
Offline
Brain Stormer
Joined: 08/08/2007
Juice: 228
Re: Re: U.S. Postal Service - Table Based. Now with Auto Update!

Funny, I actually asked similar questions a couple of months ago and some of them were already answered!... :

http://www.ubercart.org/forum/archive/110/table_based_usps_shipping_calc...

I was right, the hooks need to be implemented for this to work. would the uc guys have time to look at this and figure out how to patch it into the checkout?

however, i'm still not sure how the rates are actually tabulated. Chances are it's already happening but because no interface of this module to the products at checkout exists, there's no way to tell other than jumping in the db to look for a table i don't know the name of.