USPS Calculator

I have reworked a popular USPS PHP Rate Calculation script written by Mark Sanborn to include a few more options in the shipping calculation and also fixed a couple bugs when the user selects something other than PRIORITY. All credit is given to Mark, and if you find this script useful please consider making a donation by clicking here.

Please note that you will need to sign up for an account at USPS.com and have the account activated by sending an email to icustomercare@usps.com. The test accounts just do not work for some reason.

The Script

Click here to download

Now, to check the price of a given option, simply pass in the pounds, ounces, service type, and destination zip code to this function to be returned a dollar amount. That's it!

Please note the comments in the script. You'll notice that First Class shipments cannot weigh more than 13 ounces, and the maximum weight is 70 pounds. Please also notice that if you choose First Class, you must pick a FirstClassMailType. The options there are PARCEL, LETTER, or FLAT.

Find this article helpful?

Consider becoming a fan of our Facebook page! The link is in our fan box on the left!