Zen Cart Logo
Forums / Built-in Shipping and Payment Modules / USPS International Shipping Problem and Solution

USPS International Shipping Problem and Solution

Views: 5,313

Results 1 to 11 of 11
31 Jan 2011, 7:26 PM
#1
grafcaps_com avatar

grafcaps_com

New Zenner

Join Date:
Aug 2008
Location:
The Midwest
Posts:
11
Plugin Contributions:
0

USPS International Shipping Problem and Solution

The following applies to USPS shipping module, "USPS_UPDATE_2010_0104_B", which was the most recent version of the USPS shipping module that I could find as of January 31, 2011. FYI, I'm using Zen-Cart 1.3.9h. USPS International shipping does not work with this version of the shipping module, but I have found and corrected the problem.

I was recently notified by a customer of mine that the only available International shipping methods available from my graffiti supply website were provided by FedEx and UPS. I've always offered USPS as well, so I did some investigation. I found out that the US Postal Service has changed the format of it's XML responses for International shipments. Specifically, the <SvcDescription> tag now contains a bunch of html-encoded characters. For example, what used to be returned as:

<SvcDescription>First-Class Mail International Large Envelope</SvcDescription>

is now returned as:

<SvcDescription>First-Class Mail&lt;sup&gt;&amp;reg;&lt;/sup&gt; International Large Envelope**</SvcDescription>

This is an issue because on line 634 of /includes/modules/shipping/usps.php, the USPS server response is compared to an array of potential shipping methods which is hard-coded in on lines 114-132. For this reason, none of my available USPS shipping methods were being provided to my customers. In order to fix this problem, the array containing the shipping methods needs to be updated from:

    $this->intl_types = array(
        'Global Express' => 'Global Express Guaranteed',
        'Global Express Non-Doc Rect' => 'Global Express Guaranteed Non-Document Rectangular',
        'Global Express Non-Doc Non-Rect' => 'Global Express Guaranteed Non-Document Non-Rectangular',
        'Global Express Envelopes' => 'USPS GXG Envelopes',
        'Express Mail Int' => 'Express Mail International',
        'Express Mail Int Flat Rate Env' => 'Express Mail International Flat Rate Envelope',
        'Priority Mail International' => 'Priority Mail International',
        'Priority Mail Int Flat Rate Env' => 'Priority Mail International Flat Rate Envelope',
        'Priority Mail Int Flat Rate Box' => 'Priority Mail International Flat Rate Box',
        'Priority Mail Int Flat Rate Small Box' => 'Priority Mail International Small Flat Rate Box',
        'Priority Mail Int Flat Rate Med Box' => 'Priority Mail International Medium Flat Rate Box',
        'Priority Mail Int Flat Rate Lrg Box' => 'Priority Mail International Large Flat Rate Box',
        'First Class Mail Int Lrg Env' => 'First-Class Mail International Large Envelope',
        'First Class Mail Int Package' => 'First-Class Mail International Package',
        'First Class Mail Int Letters' => 'First-Class Mail International Letters',
        'First Class Mail Int Flats' => 'First-Class Mail International Flats',
        'First Class Mail Int Parcels' => 'First-Class Mail International Parcels'
        );

To:

    $this->intl_types = array(
        'Global Express' => 'Global Express Guaranteed&lt;sup&gt;&amp;reg;&lt;/sup&gt; (GXG)**',
        'Global Express Non-Doc Rect' => 'Global Express Guaranteed&lt;sup&gt;&amp;reg;&lt;/sup&gt; Non-Document Rectangular',
        'Global Express Non-Doc Non-Rect' => 'Global Express Guaranteed&lt;sup&gt;&amp;reg;&lt;/sup&gt; Non-Document Non-Rectangular',
        'Global Express Envelopes' => 'USPS GXG&lt;sup&gt;&amp;trade;&lt;/sup&gt; Envelopes**',
        'Express Mail Int' => 'Express Mail&lt;sup&gt;&amp;reg;&lt;/sup&gt; International',
        'Express Mail Int Flat Rate Env' => 'Express Mail&lt;sup&gt;&amp;reg;&lt;/sup&gt; International Flat Rate Envelope',
        'Priority Mail International' => 'Priority Mail&lt;sup&gt;&amp;reg;&lt;/sup&gt; International',
        'Priority Mail Int Flat Rate Env' => 'Priority Mail&lt;sup&gt;&amp;reg;&lt;/sup&gt; International Flat Rate Envelope**',
        'Priority Mail Int Flat Rate Small Box' => 'Priority Mail&lt;sup&gt;&amp;reg;&lt;/sup&gt; International Small Flat Rate Box**',
        'Priority Mail Int Flat Rate Med Box' => 'Priority Mail&lt;sup&gt;&amp;reg;&lt;/sup&gt; International Medium Flat Rate Box',
        'Priority Mail Int Flat Rate Lrg Box' => 'Priority Mail&lt;sup&gt;&amp;reg;&lt;/sup&gt; International Large Flat Rate Box',
        'First Class Mail Int Lrg Env' => 'First-Class Mail&lt;sup&gt;&amp;reg;&lt;/sup&gt; International Large Envelope**',
        'First Class Mail Int Package' => 'First-Class Mail&lt;sup&gt;&amp;reg;&lt;/sup&gt; International Package**',
        'First Class Mail Int Letter' => 'First-Class Mail&lt;sup&gt;&amp;reg;&lt;/sup&gt; International Letter**'
        );

Also, because the gobbledygook that is sent back by the USPS server is double-htmlencoded and has some extra asterisk characters, I added the following code on line 640 to clean it up:

            // strip superfluous characters sent by USPS web service
            $service = htmlspecialchars_decode(htmlspecialchars_decode($service));
            $service = str_replace('**', '', $service);

I hope this helps you before you waste a half a day troubleshooting this issue, as I did.

Ben Harold
GrafCaps

31 Jan 2011, 7:44 PM
#2
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: USPS International Shipping Problem and Solution

Could you get the current USPS January 2, 2011 C from post #26 at:
http://www.zen-cart.com/forum/showthread.php?t=171314&highlight=USPS+January+2011

and follow all of the steps to install this properly on your server and then test the current USPS shipping module and see if it doesn't work better?

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

31 Jan 2011, 7:59 PM
#3
grafcaps_com avatar

grafcaps_com

New Zenner

Join Date:
Aug 2008
Location:
The Midwest
Posts:
11
Plugin Contributions:
0

Re: USPS International Shipping Problem and Solution

Ajeh:

Could you get the current USPS January 2, 2011 C from post #26 at:
http://www.zen-cart.com/forum/showthread.php?t=171314&highlight=USPS+January+2011

and follow all of the steps to install this properly on your server and then test the current USPS shipping module and see if it doesn't work better?

Hey Linda,

I checked out the update and it looks like you fixed this problem before I even knew it existed. We both attacked it the same way, although you added the new shipping methods to the intl_types array instead of just replacing the old ones. Also, you used str_replace to fix the HTML encoded characters, whereas I used a couple of nested htmlentities_decode functions. Either way, it's virtually the same fix. I'm kind of bummed that a Google search didn't bring up this latest shipping module update. I guess I should have exhausted the forum search feature before I dove into the problem.

Thanks so much for your continued dedication to the Zen-Cart project.

Ben Harold
GrafCaps

31 Jan 2011, 8:01 PM
#4
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: USPS International Shipping Problem and Solution

Be sure to use the new USPS January 2, 2011 as there are changes in the code beyond cleaning the results from USPS ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

31 Jan 2011, 8:31 PM
#5
grafcaps_com avatar

grafcaps_com

New Zenner

Join Date:
Aug 2008
Location:
The Midwest
Posts:
11
Plugin Contributions:
0

Re: USPS International Shipping Problem and Solution

Well, I tried switching from my changes to revision C version of the USPS module as you suggested, but when I switched it over, I lost the ability to use USPS First Class Mail International Large Envelope, so I switched back to my fix. (Yes, I did uninstall and re-install the module when I switched it). It seems to be working just fine for all USPS International shipping methods that I use. Revision A is actually more similar to my fix than revision C. Mine doesn't strip or transform any characters until after all of the processing has been completed. I've attached a copy of the file that works for me.

Thanks again.

Ben Harold
GrafCaps

31 Jan 2011, 11:37 PM
#6
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: USPS International Shipping Problem and Solution

What is the Ship From?

What is the Ship To?

What is the Weight?

What are your settings in the Shipping/Packaging?

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

1 Feb 2011, 6:34 PM
#7
grafcaps_com avatar

grafcaps_com

New Zenner

Join Date:
Aug 2008
Location:
The Midwest
Posts:
11
Plugin Contributions:
0

Re: USPS International Shipping Problem and Solution

Ajeh:

What is the Ship From?

What is the Ship To?

What is the Weight?

What are your settings in the Shipping/Packaging?

The ship from address is 7488 E 171st St, Noblesville, IN 46062.

I've tried multiple Ship To addresses, including locations in Singapore, Australia and Argentina, all of which came from customers who used USPS First Class Mail International shipping in the past.

The USPS Shipping Module settings are:

Enable USPS Shipping
True

Which server to use
production

Handling Fee
0.95

Handling Per Order or Per Box
Box

Tax Class
Indiana Sales Tax

Tax Basis
Shipping

Shipping Zone
--none--

Sort Order
0

All Packages are Machinable
False

USPS Options
Display weight, Display transit time

Domestic Shipping Methods
EXPRESS, PRIORITY, FIRST CLASS, PARCEL

International Shipping Methods
USPS GXG Envelopes, Express Mail Int Flat Rate Env, Priority Mail Int Flat Rate Env, Priority Mail Int Flat Rate Med Box, First Class Mail Int Lrg Env

Debug Mode
Off

Thanks

Ben Harold
GrafCaps

1 Feb 2011, 7:02 PM
#8
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: USPS International Shipping Problem and Solution

What weight are you testing?

I can get all of these for Australia on a 1oz (.0625 lb):

United States Postal Service (1 x 0.06lbs) (Global Express Guaranteed (GXG)** (1 - 3 business days)) $47.95
United States Postal Service (1 x 0.06lbs) (Global Express Guaranteed Non-Document Rectangular (1 - 3 business days)) $47.95
United States Postal Service (1 x 0.06lbs) (Global Express Guaranteed Non-Document Non-Rectangular (1 - 3 business days)) $47.95
United States Postal Service (1 x 0.06lbs) (USPS GXG Envelopes** (1 - 3 business days)) $47.95
United States Postal Service (1 x 0.06lbs) (Express Mail International (3 - 5 business days)) $29.95
United States Postal Service (1 x 0.06lbs) (Express Mail International Flat Rate Envelope (3 - 5 business days)) $29.95
United States Postal Service (1 x 0.06lbs) (Express Mail International Legal Flat Rate Envelope (3 - 5 business days)) $29.95
United States Postal Service (1 x 0.06lbs) (Priority Mail International (6 - 10 business days)) $28.75
United States Postal Service (1 x 0.06lbs) (Priority Mail International Large Flat Rate Box (6 - 10 business days)) $58.50
United States Postal Service (1 x 0.06lbs) (Priority Mail International Medium Flat Rate Box (6 - 10 business days)) $45.50
United States Postal Service (1 x 0.06lbs) (Priority Mail International Small Flat Rate Box** (6 - 10 business days)) $13.95
United States Postal Service (1 x 0.06lbs) (Priority Mail International DVD Flat Rate Box** (6 - 10 business days)) $13.95
United States Postal Service (1 x 0.06lbs) (Priority Mail International Large Video Flat Rate Box** (6 - 10 business days)) $13.95
United States Postal Service (1 x 0.06lbs) (Priority Mail International Flat Rate Envelope** (6 - 10 business days)) $13.95
United States Postal Service (1 x 0.06lbs) (Priority Mail International Legal Flat Rate Envelope** (6 - 10 business days)) $13.95
United States Postal Service (1 x 0.06lbs) (Priority Mail International Padded Flat Rate Envelope** (6 - 10 business days)) $13.95
United States Postal Service (1 x 0.06lbs) (Priority Mail International Gift Card Flat Rate Envelope** (6 - 10 business days)) $13.95
United States Postal Service (1 x 0.06lbs) (Priority Mail International Small Flat Rate Envelope** (6 - 10 business days)) $13.95
United States Postal Service (1 x 0.06lbs) (First-Class Mail International Package** (Varies by country)) $1.44
United States Postal Service (1 x 0.06lbs) (First-Class Mail International Large Envelope** (Varies by country)) $1.24

On 1 lb, I can get:

United States Postal Service (1 x 1.00lbs) (Global Express Guaranteed (GXG)** (1 - 3 business days)) $71.75
United States Postal Service (1 x 1.00lbs) (Global Express Guaranteed Non-Document Rectangular (1 - 3 business days)) $71.75
United States Postal Service (1 x 1.00lbs) (Global Express Guaranteed Non-Document Non-Rectangular (1 - 3 business days)) $71.75
United States Postal Service (1 x 1.00lbs) (USPS GXG Envelopes** (1 - 3 business days)) $71.75
United States Postal Service (1 x 1.00lbs) (Express Mail International (3 - 5 business days)) $35.50
United States Postal Service (1 x 1.00lbs) (Express Mail International Flat Rate Envelope (3 - 5 business days)) $29.95
United States Postal Service (1 x 1.00lbs) (Express Mail International Legal Flat Rate Envelope (3 - 5 business days)) $29.95
United States Postal Service (1 x 1.00lbs) (Priority Mail International (6 - 10 business days)) $28.75
United States Postal Service (1 x 1.00lbs) (Priority Mail International Large Flat Rate Box (6 - 10 business days)) $58.50
United States Postal Service (1 x 1.00lbs) (Priority Mail International Medium Flat Rate Box (6 - 10 business days)) $45.50
United States Postal Service (1 x 1.00lbs) (Priority Mail International Small Flat Rate Box** (6 - 10 business days)) $13.95
United States Postal Service (1 x 1.00lbs) (Priority Mail International DVD Flat Rate Box** (6 - 10 business days)) $13.95
United States Postal Service (1 x 1.00lbs) (Priority Mail International Large Video Flat Rate Box** (6 - 10 business days)) $13.95
United States Postal Service (1 x 1.00lbs) (Priority Mail International Flat Rate Envelope** (6 - 10 business days)) $13.95
United States Postal Service (1 x 1.00lbs) (Priority Mail International Legal Flat Rate Envelope** (6 - 10 business days)) $13.95
United States Postal Service (1 x 1.00lbs) (Priority Mail International Padded Flat Rate Envelope** (6 - 10 business days)) $13.95
United States Postal Service (1 x 1.00lbs) (Priority Mail International Gift Card Flat Rate Envelope** (6 - 10 business days)) $13.95
United States Postal Service (1 x 1.00lbs) (Priority Mail International Small Flat Rate Envelope** (6 - 10 business days)) $13.95
United States Postal Service (1 x 1.00lbs) (First-Class Mail International Package** (Varies by country)) $10.76
United States Postal Service (1 x 1.00lbs) (First-Class Mail International Large Envelope** (Varies by country)) $10.56

On 10lbs I can get:

United States Postal Service (1 x 10.00lbs) (Global Express Guaranteed (GXG)** (1 - 3 business days)) $160.40
United States Postal Service (1 x 10.00lbs) (Global Express Guaranteed Non-Document Rectangular (1 - 3 business days)) $160.40
United States Postal Service (1 x 10.00lbs) (Global Express Guaranteed Non-Document Non-Rectangular (1 - 3 business days)) $160.40
United States Postal Service (1 x 10.00lbs) (USPS GXG Envelopes** (1 - 3 business days)) $160.40
United States Postal Service (1 x 10.00lbs) (Express Mail International (3 - 5 business days)) $86.95
United States Postal Service (1 x 10.00lbs) (Express Mail International Flat Rate Envelope (3 - 5 business days)) $29.95
United States Postal Service (1 x 10.00lbs) (Express Mail International Legal Flat Rate Envelope (3 - 5 business days)) $29.95
United States Postal Service (1 x 10.00lbs) (Priority Mail International (6 - 10 business days)) $74.40
United States Postal Service (1 x 10.00lbs) (Priority Mail International Large Flat Rate Box (6 - 10 business days)) $58.50
United States Postal Service (1 x 10.00lbs) (Priority Mail International Medium Flat Rate Box (6 - 10 business days)) $45.50

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

12 May 2011, 7:24 PM
#9
johnandrobin avatar

johnandrobin

New Zenner

Join Date:
Nov 2008
Location:
Palm Springs, California
Posts:
19
Plugin Contributions:
0

Re: USPS International Shipping Problem and Solution

Dear Linda

I have just uploaded the new USPS module as recommended in "January 2, 2011 C from post #26 at:
http://www.zen-cart.com/forum/showth...S+January+2011" above. It is working just as your example in the last post here however the first three international price quotes are for the same value.
United States Postal Service (1 x 10.00lbs) (Global Express Guaranteed (GXG)** (1 - 3 business days)) $160.40
United States Postal Service (1 x 10.00lbs) (Global Express Guaranteed Non-Document Rectangular (1 - 3 business days)) $160.40
United States Postal Service (1 x 10.00lbs) (Global Express Guaranteed Non-Document Non-Rectangular (1 - 3 business days)) $160.40

This is calculating incorrectly. The first price is correct if you use a USPS GXG standard envelope which is calculated by weight only and put your item in their envelope, the other two prices are based on weight and dimensions of the individual package to obtain the price and will be a higher price than the first. Is there a way of entering the shipping box dimensions in zen cart in order for these services to calculate correctly.

Thank you

John

12 May 2011, 10:28 PM
#10
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: USPS International Shipping Problem and Solution

No matter how I enter it on usps.com the prices come up the same ...

What is your Ship from and dimensions that you are using to obtain your quotes?

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

12 May 2011, 11:58 PM
#11
johnandrobin avatar

johnandrobin

New Zenner

Join Date:
Nov 2008
Location:
Palm Springs, California
Posts:
19
Plugin Contributions:
0

Re: USPS International Shipping Problem and Solution

On the zen cart USPS module or anywhere else in Zen Cart, there is nowhere to input the dimensions for the shipping container and that I believe is the problem. USPS calculates both the Global Express Non-Doc Rect and the Global Express Non-Doc Non-Rect by using a combination of the ship from zip code, weight and dimensions.

Currently as there is nowhere in the module, or else where in Zen Cart, to enter dimensions, these two services appear to be calculating at the same rate as Global Express. To use Global express you must use the USPS standard envelope only. If you wish to use either of the other two services (which are designed for packages) when you are on the USPS site herehttp://www.usps.com/prices/global-express-guaranteed-prices.htm it clearly states in this link "USPS GXG envelope pricing based on weight and distance. For all other items, the price is based on weight, size and distance".

If you use the USPS price calculation interface on their own website to calculate all the global express price options, The Global express price is calculated automatically and matches the zen cart modules price not just for Global Express but for all three categories, but for the other two services in question on USPS's own site, you have to provide further information to obtain the accurate cost. Once you have entered this info, ship from zip code, weight and package dimensions, the three GXG prices are different rising in cost dramatically from the basic Global express price.

As there is no place to enter the dimension information of your shipping box either in Zen Cart or when using the Zen Cart USPS module, it presumably cannot send that information to USPS via the API to accurately calculate the charges, so that is why I think the first 3 prices come out the same when using zen carts USPS module when they should be different.

So in answer to your question the ship from zip code is 92262 and my box dimensions are 9.5x5.5x6 inches with a weight of 0.5 pounds but this information is only of use if all three can be input somewhere in Zen Cart and accurately communicated through the API to USPS.

I hope this better explains the anomaly.

Thanks

John