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:
is now returned as:Code:<SvcDescription>First-Class Mail 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:Code:<SvcDescription>First-Class Mail&lt;sup&gt;&amp;reg;&lt;/sup&gt; International Large Envelope**</SvcDescription>
To: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'
);
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:$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**'
);
I hope this helps you before you waste a half a day troubleshooting this issue, as I did.PHP Code:// strip superfluous characters sent by USPS web service
$service = htmlspecialchars_decode(htmlspecialchars_decode($service));
$service = str_replace('**', '', $service);


Reply With Quote

