Page 1 of 2 12 LastLast
Results 1 to 10 of 11
  1. #1
    Join Date
    Aug 2008
    Location
    The Midwest
    Posts
    11
    Plugin Contributions
    0

    Default 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:

    Code:
    <SvcDescription>First-Class Mail International Large Envelope</SvcDescription>
    is now returned as:

    Code:
    <SvcDescription>First-Class Mail&amp;lt;sup&amp;gt;&amp;amp;reg;&amp;lt;/sup&amp;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:

    PHP Code:
        $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:

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

    PHP Code:
                // 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.

  2. #2
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default 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/showth...S+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!

  3. #3
    Join Date
    Aug 2008
    Location
    The Midwest
    Posts
    11
    Plugin Contributions
    0

    Default Re: USPS International Shipping Problem and Solution

    Quote Originally Posted by Ajeh View Post
    Could you get the current USPS January 2, 2011 C from post #26 at:
    http://www.zen-cart.com/forum/showth...S+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.

  4. #4
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default 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!

  5. #5
    Join Date
    Aug 2008
    Location
    The Midwest
    Posts
    11
    Plugin Contributions
    0

    Default 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.
    Attached Files Attached Files

  6. #6
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default 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!

  7. #7
    Join Date
    Aug 2008
    Location
    The Midwest
    Posts
    11
    Plugin Contributions
    0

    Default Re: USPS International Shipping Problem and Solution

    Quote Originally Posted by Ajeh View Post
    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

  8. #8
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default 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!

  9. #9
    Join Date
    Nov 2008
    Location
    Palm Springs, California
    Posts
    19
    Plugin Contributions
    0

    Default 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

  10. #10
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default 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!

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. v151 USPS Shipping Module is Overcharging Domestic and International Orders
    By fabienne in forum Addon Shipping Modules
    Replies: 4
    Last Post: 5 Jun 2013, 07:48 PM
  2. USPS international shipping calculation problem
    By OrionsAttic in forum Built-in Shipping and Payment Modules
    Replies: 2
    Last Post: 27 Jun 2011, 04:26 PM
  3. Replies: 237
    Last Post: 15 Jun 2011, 07:34 PM
  4. Replies: 0
    Last Post: 31 Aug 2006, 09:15 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg