Results 1 to 10 of 11

Hybrid View

  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!

 

 

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