Jump to content
bad_lemming

[Contribution] - USPS Methods

Recommended Posts

Yes. It's actually broken at the moment.

 

The USPS is feeding something like this out their API:

Media Mail<sup>®</sup>

 

When, really, they want:

Media Mail<sup>®</sup>

 

To make "Media Mail®"

 

It looks like they fed it through their HTML-ifier two times too many. Ech.

 

Anyway, I just got off the phone with the US Postal service. They say they are aware of the issue and will fix it by the close of business today (Sunday, January 2).

 

They also said that they were aware of the International rates issue, and would fix that, too. It sounded like it was related. I was less convinced.

 

If you're desperate enough to take international orders today, I'd recommend implementing some sort of flat rate shipping module until the USPS straightens this out. Those modules are not dependent on the USPS API. They work well for USPS Priority Mail, which is probably what you want for international orders, anyway. You'll have to put in the prices manually, but that's not hard.

Edited by ztwistbooks

Share this post


Link to post
Share on other sites

Yes. It's actually broken at the moment.

 

The USPS is feeding something like this out their API:

Media Mail&lt;sup&gt;&amp;reg;&lt;/sup&gt;

 

When, really, they want:

Media Mail<sup>®</sup>

 

To make "Media Mail®"

 

It looks like they fed it through their HTML-ifier two times too many. Ech.

 

Anyway, I just got off the phone with the US Postal service. They say they are aware of the issue and will fix it by the close of business today (Sunday, January 2).

 

They also said that they were aware of the International rates issue, and would fix that, too. It sounded like it was related. I was less convinced.

 

Please imagine the word "Argh" 20 feet high in flames.

 

Thank you very much for this update. I'm going to go have myself a Sunday afternoon now and forget this until tomorrow.

Share this post


Link to post
Share on other sites

Using the last two files I posted I have usps working for international working. I also have fedex installed and both are about the same prices. I checked a Us address and a address from Canada. The Usps names are not correct but customers tend to choose the lowest shipping they see anyway

 

Hope this helps

Share this post


Link to post
Share on other sites

Thanks so much for posting these files - i have applied and now domestic is back in business - international is still crunked as you stated - but that is less critical for most of my clients. THANKS for sharing!!! You are the man! (no offense if you are wo-man, it's a saying).

 

J

 

Sorry I posted the wrong files. I have it working for US on two sites Sorry I haven't gotten International to work

 

includes/modules/shipping

 

<?php

/*

$Id: usps.php 1783 2008-01-10 01:16:16Z hpdl $

 

osCommerce, Open Source E-Commerce Solutions

http://www.oscommerce.com

 

Copyright © 2008 osCommerce

 

Released under the GNU General Public License

*/

 

class usps {

var $code, $title, $description, $icon, $enabled, $countries;

 

// class constructor

function usps() {

global $order;

 

$this->code = 'usps';

$this->title = MODULE_SHIPPING_USPS_TEXT_TITLE;

$this->description = MODULE_SHIPPING_USPS_TEXT_DESCRIPTION;

$this->sort_order = MODULE_SHIPPING_USPS_SORT_ORDER;

$this->icon = DIR_WS_ICONS . 'shipping_usps.gif';

$this->tax_class = MODULE_SHIPPING_USPS_TAX_CLASS;

$this->enabled = ((MODULE_SHIPPING_USPS_STATUS == 'True') ? true : false);

 

if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_USPS_ZONE > 0) ) {

$check_flag = false;

$check_query = tep_db_query("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_SHIPPING_USPS_ZONE . "' and zone_country_id = '" . $order->delivery['country']['id'] . "' order by zone_id");

while ($check = tep_db_fetch_array($check_query)) {

if ($check['zone_id'] < 1) {

$check_flag = true;

break;

} elseif ($check['zone_id'] == $order->delivery['zone_id']) {

$check_flag = true;

break;

}

}

 

if ($check_flag == false) {

$this->enabled = false;

}

}

 

$this->types = array('EXPRESS' => 'Express Mail',

'FIRST CLASS' => 'First-Class Mail',

'PRIORITY' => 'Priority Mail',

'PARCEL' => 'Parcel Post');

 

$this->intl_types = array('Global Express Guaranteed',

'Global Express Guaranteed Non-Document Rectangular',

'Global Express Guaranteed Non-Document Non-Rectangular',

'Express Mail International (EMS)',

'Express Mail International (EMS) Flat Rate Envelope',

'Priority Mail International',

'Priority Mail International Flat Rate Envelope',

'Priority Mail International Flat Rate Box',

'First-Class Mail International');

 

$this->countries = $this->country_list();

}

 

// class methods

function quote($method = '') {

global $order, $shipping_weight, $shipping_num_boxes;

 

if ( tep_not_null($method) && (isset($this->types[$method]) || in_array($method, $this->intl_types)) ) {

$this->_setService($method);

}

 

$this->_setMachinable('False');

$this->_setContainer('None');

$this->_setSize('REGULAR');

 

// usps doesnt accept zero weight

$shipping_weight = ($shipping_weight < 0.1 ? 0.1 : $shipping_weight);

$shipping_pounds = floor ($shipping_weight);

$shipping_ounces = round(16 * ($shipping_weight - floor($shipping_weight)));

$this->_setWeight($shipping_pounds, $shipping_ounces);

 

$uspsQuote = $this->_getQuote();

 

if (is_array($uspsQuote)) {

if (isset($uspsQuote['error'])) {

$this->quotes = array('module' => $this->title,

'error' => $uspsQuote['error']);

} else {

$this->quotes = array('id' => $this->code,

'module' => $this->title . ' (' . $shipping_num_boxes . ' x ' . $shipping_weight . 'lbs)');

 

$methods = array();

$size = sizeof($uspsQuote);

for ($i=0; $i<$size; $i++) {

list($type, $cost) = each($uspsQuote[$i]);

 

$methods[] = array('id' => $type,

'title' => ((isset($this->types[$type])) ? $this->types[$type] : $type),

'cost' => ($cost + MODULE_SHIPPING_USPS_HANDLING) * $shipping_num_boxes);

}

 

$this->quotes['methods'] = $methods;

 

if ($this->tax_class > 0) {

$this->quotes['tax'] = tep_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);

}

}

} else {

$this->quotes = array('module' => $this->title,

'error' => MODULE_SHIPPING_USPS_TEXT_ERROR);

}

 

if (tep_not_null($this->icon)) $this->quotes['icon'] = tep_image($this->icon, $this->title);

 

return $this->quotes;

}

 

function check() {

if (!isset($this->_check)) {

$check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_SHIPPING_USPS_STATUS'");

$this->_check = tep_db_num_rows($check_query);

}

return $this->_check;

}

 

function install() {

tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable USPS Shipping', 'MODULE_SHIPPING_USPS_STATUS', 'True', 'Do you want to offer USPS shipping?', '6', '0', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())");

tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Enter the USPS User ID', 'MODULE_SHIPPING_USPS_USERID', 'NONE', 'Enter the USPS USERID assigned to you.', '6', '0', now())");

tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Enter the USPS Password', 'MODULE_SHIPPING_USPS_PASSWORD', 'NONE', 'See USERID, above.', '6', '0', now())");

tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Handling Fee', 'MODULE_SHIPPING_USPS_HANDLING', '0', 'Handling fee for this shipping method.', '6', '0', now())");

tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Tax Class', 'MODULE_SHIPPING_USPS_TAX_CLASS', '0', 'Use the following tax class on the shipping fee.', '6', '0', 'tep_get_tax_class_title', 'tep_cfg_pull_down_tax_classes(', now())");

tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Shipping Zone', 'MODULE_SHIPPING_USPS_ZONE', '0', 'If a zone is selected, only enable this shipping method for that zone.', '6', '0', 'tep_get_zone_class_title', 'tep_cfg_pull_down_zone_classes(', now())");

tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_SHIPPING_USPS_SORT_ORDER', '0', 'Sort order of display.', '6', '0', now())");

}

 

function remove() {

tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");

}

 

function keys() {

return array('MODULE_SHIPPING_USPS_STATUS', 'MODULE_SHIPPING_USPS_USERID', 'MODULE_SHIPPING_USPS_PASSWORD', 'MODULE_SHIPPING_USPS_HANDLING', 'MODULE_SHIPPING_USPS_TAX_CLASS', 'MODULE_SHIPPING_USPS_ZONE', 'MODULE_SHIPPING_USPS_SORT_ORDER');

}

 

function _setService($service) {

$this->service = $service;

}

 

function _setWeight($pounds, $ounces=0) {

$this->pounds = $pounds;

$this->ounces = $ounces;

}

 

function _setContainer($container) {

$this->container = $container;

}

 

function _setSize($size) {

$this->size = $size;

}

 

function _setMachinable($machinable) {

$this->machinable = $machinable;

}

 

function _getQuote() {

global $order;

 

if ($order->delivery['country']['id'] == SHIPPING_ORIGIN_COUNTRY) {

$request = '<RateRequest USERID="' . MODULE_SHIPPING_USPS_USERID . '" PASSWORD="' . MODULE_SHIPPING_USPS_PASSWORD . '">';

$services_count = 0;

 

if (isset($this->service)) {

$this->types = array($this->service => $this->types[$this->service]);

}

 

$dest_zip = str_replace(' ', '', $order->delivery['postcode']);

if ($order->delivery['country']['iso_code_2'] == 'US') $dest_zip = substr($dest_zip, 0, 5);

 

reset($this->types);

while (list($key, $value) = each($this->types)) {

$request .= '<Package ID="' . $services_count . '">' .

'<Service>' . $key . '</Service>' .

'<ZipOrigination>' . SHIPPING_ORIGIN_ZIP . '</ZipOrigination>' .

'<ZipDestination>' . $dest_zip . '</ZipDestination>' .

'<Pounds>' . $this->pounds . '</Pounds>' .

'<Ounces>' . $this->ounces . '</Ounces>' .

'<Container>' . $this->container . '</Container>' .

'<Size>' . $this->size . '</Size>' .

'<Machinable>' . $this->machinable . '</Machinable>' .

'</Package>';

$services_count++;

}

$request .= '</RateRequest>';

 

$request = 'API=Rate&XML=' . urlencode($request);

} else {

$request = '<IntlRateRequest USERID="' . MODULE_SHIPPING_USPS_USERID . '" PASSWORD="' . MODULE_SHIPPING_USPS_PASSWORD . '">' .

'<Package ID="0">' .

'<Pounds>' . $this->pounds . '</Pounds>' .

'<Ounces>' . $this->ounces . '</Ounces>' .

'<MailType>Package</MailType>' .

'<Country>' . $this->countries[$order->delivery['country']['iso_code_2']] . '</Country>' .

'</Package>' .

'</IntlRateRequest>';

 

$request = 'API=IntlRate&XML=' . urlencode($request);

}

 

$body = '';

 

if (!class_exists('httpClient')) {

include('includes/classes/http_client.php');

}

 

$http = new httpClient();

if ($http->Connect('production.shippingapis.com', 80)) {

$http->addHeader('Host', 'production.shippingapis.com');

$http->addHeader('User-Agent', 'osCommerce');

$http->addHeader('Connection', 'Close');

 

if ($http->Get('/shippingapi.dll?' . $request)) $body = $http->getBody();

 

$http->Disconnect();

} else {

return false;

}

 

$response = array();

while (true) {

if ($start = strpos($body, '<Package ID=')) {

$body = substr($body, $start);

$end = strpos($body, '</Package>');

$response[] = substr($body, 0, $end+10);

$body = substr($body, $end+9);

} else {

break;

}

}

 

$rates = array();

if ($order->delivery['country']['id'] == SHIPPING_ORIGIN_COUNTRY) {

if (sizeof($response) == '1') {

if (ereg('<Error>', $response[0])) {

$number = ereg('<Number>(.*)</Number>', $response[0], $regs);

$number = $regs[1];

$description = ereg('<Description>(.*)</Description>', $response[0], $regs);

$description = $regs[1];

 

return array('error' => $number . ' - ' . $description);

}

}

 

$n = sizeof($response);

for ($i=0; $i<$n; $i++) {

if (strpos($response[$i], '<Postage>')) {

$service = ereg('<Service>(.*)</Service>', $response[$i], $regs);

$service = $regs[1];

$postage = ereg('<Postage>(.*)</Postage>', $response[$i], $regs);

$postage = $regs[1];

 

$rates[] = array($service => $postage);

}

}

} else {

if (ereg('<Error>', $response[0])) {

$number = ereg('<Number>(.*)</Number>', $response[0], $regs);

$number = $regs[1];

$description = ereg('<Description>(.*)</Description>', $response[0], $regs);

$description = $regs[1];

 

return array('error' => $number . ' - ' . $description);

} else {

$body = $response[0];

$services = array();

while (true) {

if ($start = strpos($body, '<Service ID=')) {

$body = substr($body, $start);

$end = strpos($body, '</Service>');

$services[] = substr($body, 0, $end+10);

$body = substr($body, $end+9);

} else {

break;

}

}

 

$size = sizeof($services);

for ($i=0, $n=$size; $i<$n; $i++) {

if (strpos($services[$i], '<Postage>')) {

$service = ereg('<SvcDescription>(.*)</SvcDescription>', $services[$i], $regs);

$service = $regs[1];

$postage = ereg('<Postage>(.*)</Postage>', $services[$i], $regs);

$postage = $regs[1];

 

if (isset($this->service) && ($service != $this->service) ) {

continue;

}

 

$rates[] = array($service => $postage);

}

}

}

}

 

return ((sizeof($rates) > 0) ? $rates : false);

}

 

function country_list() {

$list = array('AF' => 'Afghanistan',

'AL' => 'Albania',

'DZ' => 'Algeria',

'AD' => 'Andorra',

'AO' => 'Angola',

'AI' => 'Anguilla',

'AG' => 'Antigua and Barbuda',

'AR' => 'Argentina',

'AM' => 'Armenia',

'AW' => 'Aruba',

'AU' => 'Australia',

'AT' => 'Austria',

'AZ' => 'Azerbaijan',

'BS' => 'Bahamas',

'BH' => 'Bahrain',

'BD' => 'Bangladesh',

'BB' => 'Barbados',

'BY' => 'Belarus',

'BE' => 'Belgium',

'BZ' => 'Belize',

'BJ' => 'Benin',

'BM' => 'Bermuda',

'BT' => 'Bhutan',

'BO' => 'Bolivia',

'BA' => 'Bosnia-Herzegovina',

'BW' => 'Botswana',

'BR' => 'Brazil',

'VG' => 'British Virgin Islands',

'BN' => 'Brunei Darussalam',

'BG' => 'Bulgaria',

'BF' => 'Burkina Faso',

'MM' => 'Burma',

'BI' => 'Burundi',

'KH' => 'Cambodia',

'CM' => 'Cameroon',

'CA' => 'Canada',

'CV' => 'Cape Verde',

'KY' => 'Cayman Islands',

'CF' => 'Central African Republic',

'TD' => 'Chad',

'CL' => 'Chile',

'CN' => 'China',

'CX' => 'Christmas Island (Australia)',

'CC' => 'Cocos Island (Australia)',

'CO' => 'Colombia',

'KM' => 'Comoros',

'CG' => 'Congo (Brazzaville),Republic of the',

'ZR' => 'Congo, Democratic Republic of the',

'CK' => 'Cook Islands (New Zealand)',

'CR' => 'Costa Rica',

'CI' => 'Cote d\'Ivoire (Ivory Coast)',

'HR' => 'Croatia',

'CU' => 'Cuba',

'CY' => 'Cyprus',

'CZ' => 'Czech Republic',

'DK' => 'Denmark',

'DJ' => 'Djibouti',

'DM' => 'Dominica',

'DO' => 'Dominican Republic',

'TP' => 'East Timor (Indonesia)',

'EC' => 'Ecuador',

'EG' => 'Egypt',

'SV' => 'El Salvador',

'GQ' => 'Equatorial Guinea',

'ER' => 'Eritrea',

'EE' => 'Estonia',

'ET' => 'Ethiopia',

'FK' => 'Falkland Islands',

'FO' => 'Faroe Islands',

'FJ' => 'Fiji',

'FI' => 'Finland',

'FR' => 'France',

'GF' => 'French Guiana',

'PF' => 'French Polynesia',

'GA' => 'Gabon',

'GM' => 'Gambia',

'GE' => 'Georgia, Republic of',

'DE' => 'Germany',

'GH' => 'Ghana',

'GI' => 'Gibraltar',

'GB' => 'Great Britain and Northern Ireland',

'GR' => 'Greece',

'GL' => 'Greenland',

'GD' => 'Grenada',

'GP' => 'Guadeloupe',

'GT' => 'Guatemala',

'GN' => 'Guinea',

'GW' => 'Guinea-Bissau',

'GY' => 'Guyana',

'HT' => 'Haiti',

'HN' => 'Honduras',

'HK' => 'Hong Kong',

'HU' => 'Hungary',

'IS' => 'Iceland',

'IN' => 'India',

'ID' => 'Indonesia',

'IR' => 'Iran',

'IQ' => 'Iraq',

'IE' => 'Ireland',

'IL' => 'Israel',

'IT' => 'Italy',

'JM' => 'Jamaica',

'JP' => 'Japan',

'JO' => 'Jordan',

'KZ' => 'Kazakhstan',

'KE' => 'Kenya',

'KI' => 'Kiribati',

'KW' => 'Kuwait',

'KG' => 'Kyrgyzstan',

'LA' => 'Laos',

'LV' => 'Latvia',

'LB' => 'Lebanon',

'LS' => 'Lesotho',

'LR' => 'Liberia',

'LY' => 'Libya',

'LI' => 'Liechtenstein',

'LT' => 'Lithuania',

'LU' => 'Luxembourg',

'MO' => 'Macao',

'MK' => 'Macedonia, Republic of',

'MG' => 'Madagascar',

'MW' => 'Malawi',

'MY' => 'Malaysia',

'MV' => 'Maldives',

'ML' => 'Mali',

'MT' => 'Malta',

'MQ' => 'Martinique',

'MR' => 'Mauritania',

'MU' => 'Mauritius',

'YT' => 'Mayotte (France)',

'MX' => 'Mexico',

'MD' => 'Moldova',

'MC' => 'Monaco (France)',

'MN' => 'Mongolia',

'MS' => 'Montserrat',

'MA' => 'Morocco',

'MZ' => 'Mozambique',

'NA' => 'Namibia',

'NR' => 'Nauru',

'NP' => 'Nepal',

'NL' => 'Netherlands',

'AN' => 'Netherlands Antilles',

'NC' => 'New Caledonia',

'NZ' => 'New Zealand',

'NI' => 'Nicaragua',

'NE' => 'Niger',

'NG' => 'Nigeria',

'KP' => 'North Korea (Korea, Democratic People\'s Republic of)',

'NO' => 'Norway',

'OM' => 'Oman',

'PK' => 'Pakistan',

'PA' => 'Panama',

'PG' => 'Papua New Guinea',

'PY' => 'Paraguay',

'PE' => 'Peru',

'PH' => 'Philippines',

'PN' => 'Pitcairn Island',

'PL' => 'Poland',

'PT' => 'Portugal',

'QA' => 'Qatar',

'RE' => 'Reunion',

'RO' => 'Romania',

'RU' => 'Russia',

'RW' => 'Rwanda',

'SH' => 'Saint Helena',

'KN' => 'Saint Kitts (St. Christopher and Nevis)',

'LC' => 'Saint Lucia',

'PM' => 'Saint Pierre and Miquelon',

'VC' => 'Saint Vincent and the Grenadines',

'SM' => 'San Marino',

'ST' => 'Sao Tome and Principe',

'SA' => 'Saudi Arabia',

'SN' => 'Senegal',

'YU' => 'Serbia-Montenegro',

'SC' => 'Seychelles',

'SL' => 'Sierra Leone',

'SG' => 'Singapore',

'SK' => 'Slovak Republic',

'SI' => 'Slovenia',

'SB' => 'Solomon Islands',

'SO' => 'Somalia',

'ZA' => 'South Africa',

'GS' => 'South Georgia (Falkland Islands)',

'KR' => 'South Korea (Korea, Republic of)',

'ES' => 'Spain',

'LK' => 'Sri Lanka',

'SD' => 'Sudan',

'SR' => 'Suriname',

'SZ' => 'Swaziland',

'SE' => 'Sweden',

'CH' => 'Switzerland',

'SY' => 'Syrian Arab Republic',

'TW' => 'Taiwan',

'TJ' => 'Tajikistan',

'TZ' => 'Tanzania',

'TH' => 'Thailand',

'TG' => 'Togo',

'TK' => 'Tokelau (Union) Group (Western Samoa)',

'TO' => 'Tonga',

'TT' => 'Trinidad and Tobago',

'TN' => 'Tunisia',

'TR' => 'Turkey',

'TM' => 'Turkmenistan',

'TC' => 'Turks and Caicos Islands',

'TV' => 'Tuvalu',

'UG' => 'Uganda',

'UA' => 'Ukraine',

'AE' => 'United Arab Emirates',

'UY' => 'Uruguay',

'UZ' => 'Uzbekistan',

'VU' => 'Vanuatu',

'VA' => 'Vatican City',

'VE' => 'Venezuela',

'VN' => 'Vietnam',

'WF' => 'Wallis and Futuna Islands',

'WS' => 'Western Samoa',

'YE' => 'Yemen',

'ZM' => 'Zambia',

'ZW' => 'Zimbabwe');

 

return $list;

}

}

?>

 

/includes/languages/english/modules/

 

<?php

/*

$Id: usps.php 1739 2007-12-20 00:52:16Z hpdl $

 

osCommerce, Open Source E-Commerce Solutions

http://www.oscommerce.com

 

Copyright © 2002 osCommerce

 

Released under the GNU General Public License

*/

 

define('MODULE_SHIPPING_USPS_TEXT_TITLE', 'United States Postal Service');

define('MODULE_SHIPPING_USPS_TEXT_DESCRIPTION', 'United States Postal Service<br><br>You will need to have registered an account with USPS at http://www.uspsprioritymail.com/et_regcert.html to use this module<br><br>USPS expects you to use pounds as weight measure for your products.');

define('MODULE_SHIPPING_USPS_TEXT_OPT_PP', 'Parcel Post');

define('MODULE_SHIPPING_USPS_TEXT_OPT_PM', 'Priority Mail');

define('MODULE_SHIPPING_USPS_TEXT_OPT_EX', 'Express Mail');

define('MODULE_SHIPPING_USPS_TEXT_ERROR', 'An error occured with the USPS shipping calculations.<br>If you prefer to use USPS as your shipping method, please contact the store owner.');

?>

Share this post


Link to post
Share on other sites

when i called usps the guy flat out denied anything was wrong on their end.

it must have been blind luck that you got the one USPS employee with a sodium penthatol addiction...

Share this post


Link to post
Share on other sites

I am having the same issue.

 

International rates are completely broken, however, part of domestic rates are working. I am getting feed result like Media Mail<sup>&reg;</sup>, Name feed back funny looking however, rates are still there, well.... kinda off, we are still able to take domestic orders despite the name class is looking funny, BUT we just realize there is another failed issued, the handling fee set in admin for the domestic shipping is no longer working. Rate given to customers are actually as posted, it had completely ignored the handling fee set in admin. Not sure what they have done to affect that handling fee tags.

 

Aghh... I hope USPS are aware of 3 issues and will have these be fixed ASAP.

Share this post


Link to post
Share on other sites

I am having the same issue.

 

International rates are completely broken, however, part of domestic rates are working. I am getting feed result like Media Mail<sup>&reg;</sup>, Name feed back funny looking however, rates are still there, well.... kinda off, we are still able to take domestic orders despite the name class is looking funny, BUT we just realize there is another failed issued, the handling fee set in admin for the domestic shipping is no longer working. Rate given to customers are actually as posted, it had completely ignored the handling fee set in admin. Not sure what they have done to affect that handling fee tags.

 

Aghh... I hope USPS are aware of 3 issues and will have these be fixed ASAP.

 

 

they added the "registered" sign after their shipping methods, which screws up the display. I partially fixed it by using the function htmlspecialchars_decode after the MailService, but I still have the <sup> tags showing up, cannot get rid of them with a preg_replace, it breaks the code...

 

$service = preg_match('/<MailService>(.*)<\/MailService>/', $response[$i], $regs);

$service = htmlspecialchars_decode($regs[1]);

 

But they changed the international options big time, and their documentations doesn't seem to have been updated: in that case, their XML response examples should show the "registered" signs!

 

Still no clue what they did....

Share this post


Link to post
Share on other sites

Lat year after their changed, I had the good idea to uncomment the debug line to mail myself the XML response, so I did that today so we can compare today's response and one from last year.

 

Besides the registered sign, there are other differences.

 

If somebody is skilled enough to know what to do to fix this, here are the two responses so you can compare (besides the differences in price quote and value of course):

 

 

2010:

 

\
Areas Served: All
</expressmail>
<areasserved>
Please reference Express Mail for Areas Served.
</areasserved>
<service id="4">
<pounds>
	0
</pounds>
<ounces>
	12.96
</ounces>
<mailtype>
	Package
</mailtype>
<country>
	CANADA
</country>
<postage>
	53.50
</postage>
<valueofcontents>
	5.95
</valueofcontents>
<insurance>
	0.00
</insurance>
<svccommitments>
	1 - 3 Days
</svccommitments>
<svcdescription>
	Global Express Guaranteed (GXG)
</svcdescription>
<maxdimensions>
	Max. length 46", width 35", height 46" and max. length plus girth combined 108"
</maxdimensions>
<maxweight>
	70
</maxweight>
</service>
<service id="6">
<pounds>
	0
</pounds>
<ounces>
	12.96
</ounces>
<mailtype>
	Package
</mailtype>
<country>
	CANADA
</country>
<postage>
	53.50
</postage>
<valueofcontents>
	5.95
</valueofcontents>
<insurance>
	0.00
</insurance>
<svccommitments>
	1 - 3 Days
</svccommitments>
<svcdescription>
	Global Express Guaranteed Non-Document Rectangular
</svcdescription>
<maxdimensions>
	Max. length 46", width 35", height 46" and max. length plus girth combined 108"
</maxdimensions>
<maxweight>
	70
</maxweight>
</service>
<service id="7">
<pounds>
	0
</pounds>
<ounces>
	12.96
</ounces>
<mailtype>
	Package
</mailtype>
<country>
	CANADA
</country>
<postage>
	53.50
</postage>
<valueofcontents>
	5.95
</valueofcontents>
<insurance>
	0.00
</insurance>
<svccommitments>
	1 - 3 Days
</svccommitments>
<svcdescription>
	Global Express Guaranteed Non-Document Non-Rectangular
</svcdescription>
<maxdimensions>
	Max. length 46", width 35", height 46" and max. length plus girth combined 108"
</maxdimensions>
<maxweight>
	70
</maxweight>
</service>
<service id="12">
<pounds>
	0
</pounds>
<ounces>
	12.96
</ounces>
<mailtype>
	Package
</mailtype>
<country>
	CANADA
</country>
<postage>
	53.50
</postage>
<valueofcontents>
	5.95
</valueofcontents>
<insurance>
	0.00
</insurance>
<svccommitments>
	1 - 3 Days
</svccommitments>
<svcdescription>
	USPS GXG Envelopes
</svcdescription>
<maxdimensions>
	Cardboard envelope has a dimension of 9 1/2" X 12 1/2" and GXG tyvek envelope has a dimension of 12 1/2" X 15 1/2"
</maxdimensions>
<maxweight>
	70
</maxweight>
</service>
<service id="1">
<pounds>
	0
</pounds>
<ounces>
	12.96
</ounces>
<mailtype>
	Package
</mailtype>
<country>
	CANADA
</country>
<postage>
	31.50
</postage>
<valueofcontents>
	5.95
</valueofcontents>
<insurance>
	0.00
</insurance>
<svccommitments>
	5 Days
</svccommitments>
<svcdescription>
	Express Mail International
</svcdescription>
<maxdimensions>
	Max. length 42", max. length plus girth combined 79"
</maxdimensions>
<maxweight>
	66
</maxweight>
</service>
<service id="10">
<pounds>
	0
</pounds>
<ounces>
	12.96
</ounces>
<mailtype>
	Package
</mailtype>
<country>
	CANADA
</country>
<postage>
	26.95
</postage>
<valueofcontents>
	5.95
</valueofcontents>
<insurance>
	0.00
</insurance>
<svccommitments>
	5 Days
</svccommitments>
<svcdescription>
	Express Mail International Flat Rate Envelope
</svcdescription>
<maxdimensions>
	USPS Supplied Envelope: 9 1/2" x 12 1/2"
</maxdimensions>
<maxweight>
	66
</maxweight>
</service>
<service id="2">
<pounds>
	0
</pounds>
<ounces>
	12.96
</ounces>
<mailtype>
	Package
</mailtype>
<country>
	CANADA
</country>
<postage>
	20.00
</postage>
<valueofcontents>
	5.95
</valueofcontents>
<insurance>
	1.75
</insurance>
<parcelindemnitycoverage>
	5.95
</parcelindemnitycoverage>
<svccommitments>
	6 - 10 Days
</svccommitments>
<svcdescription>
	Priority Mail International
</svcdescription>
<maxdimensions>
	Max. length 60", max. length plus girth combined 108"
</maxdimensions>
<maxweight>
	66
</maxweight>
</service>
<service id="11">
<pounds>
	0
</pounds>
<ounces>
	12.96
</ounces>
<mailtype>
	Package
</mailtype>
<country>
	CANADA
</country>
<postage>
	33.95
</postage>
<valueofcontents>
	5.95
</valueofcontents>
<insurance>
	1.75
</insurance>
<parcelindemnitycoverage>
	5.95
</parcelindemnitycoverage>
<svccommitments>
	6 - 10 Days
</svccommitments>
<svcdescription>
	Priority Mail International Large Flat Rate Box
</svcdescription>
<maxdimensions>
	USPS Supplied Large Box: 12" x 12" x 5 1/2". Maximum weight 20 pounds.
</maxdimensions>
<maxweight>
	20
</maxweight>
</service>
<service id="9">
<pounds>
	0
</pounds>
<ounces>
	12.96
</ounces>
<mailtype>
	Package
</mailtype>
<country>
	CANADA
</country>
<postage>
	26.95
</postage>
<valueofcontents>
	5.95
</valueofcontents>
<insurance>
	1.75
</insurance>
<parcelindemnitycoverage>
	5.95
</parcelindemnitycoverage>
<svccommitments>
	6 - 10 Days
</svccommitments>
<svcdescription>
	Priority Mail International Medium Flat Rate Box
</svcdescription>
<maxdimensions>
	USPS Supplied Medium Box: 13 5/8" x 11 7/8" x 3 3/8" or 11" x 8 1/2" x 5 1/2". Maximum weight 20 pounds.
</maxdimensions>
<maxweight>
	20
</maxweight>
</service>
<service id="16">
<pounds>
	0
</pounds>
<ounces>
	12.96
</ounces>
<mailtype>
	Package
</mailtype>
<country>
	CANADA
</country>
<postage>
	11.45
</postage>
<valueofcontents>
	5.95
</valueofcontents>
<inscomment>
	DESTINATION
</inscomment>
<svccommitments>
	6 - 10 Days
</svccommitments>
<svcdescription>
	Priority Mail International Small Flat Rate Box
</svcdescription>
<maxdimensions>
	USPS Supplied Small Box: 8 5/8" x 5 3/8" x 1 5/8". Maximum weight 4 pounds.
</maxdimensions>
<maxweight>
	4
</maxweight>
</service>
<service id="8">
<pounds>
	0
</pounds>
<ounces>
	12.96
</ounces>
<mailtype>
	Package
</mailtype>
<country>
	CANADA
</country>
<postage>
	11.45
</postage>
<valueofcontents>
	5.95
</valueofcontents>
<inscomment>
	DESTINATION
</inscomment>
<svccommitments>
	6 - 10 Days
</svccommitments>
<svcdescription>
	Priority Mail International Flat Rate Envelope
</svcdescription>
<maxdimensions>
	USPS Supplied Envelope: 9 1/2" x 12 1/2". Maximum weight 4 pounds.
</maxdimensions>
<maxweight>
	4
</maxweight>
</service>
<service id="15">
<pounds>
	0
</pounds>
<ounces>
	12.96
</ounces>
<mailtype>
	Package
</mailtype>
<country>
	CANADA
</country>
<postage>
	5.01
</postage>
<valueofcontents>
	5.95
</valueofcontents>
<inscomment>
	DESTINATION
</inscomment>
<svccommitments>
	Varies
</svccommitments>
<svcdescription>
	First-Class Mail International Package
</svcdescription>
<maxdimensions>
	Other than rolls: Max. length 24", max length, height and depth (thickness) combined 36" Rolls: Max. length 36". Max length and twice the diameter combined 42"
</maxdimensions>
<maxweight>
	4
</maxweight>
</service>
<service id="14">
<pounds>
	0
</pounds>
<ounces>
	12.96
</ounces>
<mailtype>
	Package
</mailtype>
<country>
	CANADA
</country>
<postage>
	4.81
</postage>
<valueofcontents>
	5.95
</valueofcontents>
<inscomment>
	DESTINATION
</inscomment>
<svccommitments>
	Varies
</svccommitments>
<svcdescription>
	First-Class Mail International Large Envelope
</svcdescription>
<maxdimensions>
	Max. length 15", height 12" or thickness 3/4"
</maxdimensions>
<maxweight>
	4
</maxweight>
</service>
</package>
</intlrateresponse>

 

and 2011

 

 

Areas Served: All
</expressmail>
<areasserved>
Please reference Express Mail for Areas Served.
</areasserved>
<service id="4">
<pounds>
	1
</pounds>
<ounces>
	7.2
</ounces>
<mailtype>
	Package
</mailtype>
<country>
	CANADA
</country>
<postage>
	59.75
</postage>
<valueofcontents>
	15.40
</valueofcontents>
<insurance>
	0.00
</insurance>
<svccommitments>
	1 - 3 business days
</svccommitments>
<svcdescription>
	Global Express Guaranteed&lt;sup&gt;&amp;reg;&lt;/sup&gt; (GXG)**
</svcdescription>
<maxdimensions>
	Max. length 46", width 35", height 46" and max. length plus girth combined 108"
</maxdimensions>
<maxweight>
	70
</maxweight>
</service>
<service id="6">
<pounds>
	1
</pounds>
<ounces>
	7.2
</ounces>
<mailtype>
	Package
</mailtype>
<country>
	CANADA
</country>
<postage>
	59.75
</postage>
<valueofcontents>
	15.40
</valueofcontents>
<insurance>
	0.00
</insurance>
<svccommitments>
	1 - 3 business days
</svccommitments>
<svcdescription>
	Global Express Guaranteed&lt;sup&gt;&amp;reg;&lt;/sup&gt; Non-Document Rectangular
</svcdescription>
<maxdimensions>
	Max. length 46", width 35", height 46" and max. length plus girth combined 108"
</maxdimensions>
<maxweight>
	70
</maxweight>
</service>
<service id="7">
<pounds>
	1
</pounds>
<ounces>
	7.2
</ounces>
<mailtype>
	Package
</mailtype>
<country>
	CANADA
</country>
<postage>
	59.75
</postage>
<valueofcontents>
	15.40
</valueofcontents>
<insurance>
	0.00
</insurance>
<svccommitments>
	1 - 3 business days
</svccommitments>
<svcdescription>
	Global Express Guaranteed&lt;sup&gt;&amp;reg;&lt;/sup&gt; Non-Document Non-Rectangular
</svcdescription>
<maxdimensions>
	Max. length 46", width 35", height 46" and max. length plus girth combined 108"
</maxdimensions>
<maxweight>
	70
</maxweight>
</service>
<service id="12">
<pounds>
	1
</pounds>
<ounces>
	7.2
</ounces>
<mailtype>
	Package
</mailtype>
<country>
	CANADA
</country>
<postage>
	59.75
</postage>
<valueofcontents>
	15.40
</valueofcontents>
<insurance>
	0.00
</insurance>
<svccommitments>
	1 - 3 business days
</svccommitments>
<svcdescription>
	USPS GXG&lt;sup&gt;&amp;trade;&lt;/sup&gt; Envelopes**
</svcdescription>
<maxdimensions>
	Cardboard envelope has a dimension of 12-1/2" x 9-1/2" and GXG tyvek envelope has a dimension of 15-1/2" x 12-1/2"
</maxdimensions>
<maxweight>
	70
</maxweight>
</service>
<service id="1">
<pounds>
	1
</pounds>
<ounces>
	7.2
</ounces>
<mailtype>
	Package
</mailtype>
<country>
	CANADA
</country>
<postage>
	36.15
</postage>
<valueofcontents>
	15.40
</valueofcontents>
<insurance>
	0.00
</insurance>
<svccommitments>
	3 - 5 business days
</svccommitments>
<svcdescription>
	Express Mail&lt;sup&gt;&amp;reg;&lt;/sup&gt; International
</svcdescription>
<maxdimensions>
	Max. length 42", max. length plus girth combined 79"
</maxdimensions>
<maxweight>
	66
</maxweight>
</service>
<service id="10">
<pounds>
	1
</pounds>
<ounces>
	7.2
</ounces>
<mailtype>
	Package
</mailtype>
<country>
	CANADA
</country>
<postage>
	26.95
</postage>
<valueofcontents>
	15.40
</valueofcontents>
<insurance>
	0.00
</insurance>
<svccommitments>
	3 - 5 business days
</svccommitments>
<svcdescription>
	Express Mail&lt;sup&gt;&amp;reg;&lt;/sup&gt; International Flat Rate Envelope
</svcdescription>
<maxdimensions>
	USPS-Produced Envelope: 12-1/2" x 9-1/2"
</maxdimensions>
<maxweight>
	66
</maxweight>
</service>
<service id="17">
<pounds>
	1
</pounds>
<ounces>
	7.2
</ounces>
<mailtype>
	Package
</mailtype>
<country>
	CANADA
</country>
<postage>
	26.95
</postage>
<valueofcontents>
	15.40
</valueofcontents>
<insurance>
	0.00
</insurance>
<svccommitments>
	3 - 5 business days
</svccommitments>
<svcdescription>
	Express Mail&lt;sup&gt;&amp;reg;&lt;/sup&gt; International Legal Flat Rate Envelope
</svcdescription>
<maxdimensions>
	USPS-Produced Envelope: 15" x 9-1/2"
</maxdimensions>
<maxweight>
	66
</maxweight>
</service>
<service id="2">
<pounds>
	1
</pounds>
<ounces>
	7.2
</ounces>
<mailtype>
	Package
</mailtype>
<country>
	CANADA
</country>
<postage>
	23.10
</postage>
<valueofcontents>
	15.40
</valueofcontents>
<insurance>
	2.30
</insurance>
<parcelindemnitycoverage>
	15.40
</parcelindemnitycoverage>
<svccommitments>
	6 - 10 business days
</svccommitments>
<svcdescription>
	Priority Mail&lt;sup&gt;&amp;reg;&lt;/sup&gt; International
</svcdescription>
<maxdimensions>
	Max. length 79", max. length plus girth 108"
</maxdimensions>
<maxweight>
	66
</maxweight>
</service>
<service id="11">
<pounds>
	1
</pounds>
<ounces>
	7.2
</ounces>
<mailtype>
	Package
</mailtype>
<country>
	CANADA
</country>
<postage>
	35.50
</postage>
<valueofcontents>
	15.40
</valueofcontents>
<insurance>
	2.30
</insurance>
<parcelindemnitycoverage>
	15.40
</parcelindemnitycoverage>
<svccommitments>
	6 - 10 business days
</svccommitments>
<svcdescription>
	Priority Mail&lt;sup&gt;&amp;reg;&lt;/sup&gt; International Large Flat Rate Box
</svcdescription>
<maxdimensions>
	USPS-Produced Large Box: 12" x 12" x 5-1/2".<br>Maximum weight 20 pounds.
</maxdimensions>
<maxweight>
	20
</maxweight>
</service>
<service id="9">
<pounds>
	1
</pounds>
<ounces>
	7.2
</ounces>
<mailtype>
	Package
</mailtype>
<country>
	CANADA
</country>
<postage>
	27.95
</postage>
<valueofcontents>
	15.40
</valueofcontents>
<insurance>
	2.30
</insurance>
<parcelindemnitycoverage>
	15.40
</parcelindemnitycoverage>
<svccommitments>
	6 - 10 business days
</svccommitments>
<svcdescription>
	Priority Mail&lt;sup&gt;&amp;reg;&lt;/sup&gt; International Medium Flat Rate Box
</svcdescription>
<maxdimensions>
	USPS-Produced Medium Box:<br>13-5/8" x 11-7/8" x 3-3/8" or 11" x 8-1/2" x 5-1/2".<br>Maximum weight 20 pounds.
</maxdimensions>
<maxweight>
	20
</maxweight>
</service>
<service id="16">
<pounds>
	1
</pounds>
<ounces>
	7.2
</ounces>
<mailtype>
	Package
</mailtype>
<country>
	CANADA
</country>
<postage>
	11.95
</postage>
<valueofcontents>
	15.40
</valueofcontents>
<inscomment>
	SERVICE
</inscomment>
<svccommitments>
	6 - 10 business days
</svccommitments>
<svcdescription>
	Priority Mail&lt;sup&gt;&amp;reg;&lt;/sup&gt; International Small Flat Rate Box**
</svcdescription>
<maxdimensions>
	USPS-Produced Small Box: 8-5/8" x 5-3/8" x 1-5/8".<br>Maximum weight 4 pounds.
</maxdimensions>
<maxweight>
	4
</maxweight>
</service>
<service id="24">
<pounds>
	1
</pounds>
<ounces>
	7.2
</ounces>
<mailtype>
	Package
</mailtype>
<country>
	CANADA
</country>
<postage>
	11.95
</postage>
<valueofcontents>
	15.40
</valueofcontents>
<inscomment>
	SERVICE
</inscomment>
<svccommitments>
	6 - 10 business days
</svccommitments>
<svcdescription>
	Priority Mail&lt;sup&gt;&amp;reg;&lt;/sup&gt; International DVD Flat Rate Box**
</svcdescription>
<maxdimensions>
	USPS-Produced DVD Box: 7-9/16" x 5-7/16" x 1-3/8".<br>Maximum weight 4 pounds.
</maxdimensions>
<maxweight>
	4
</maxweight>
</service>
<service id="25">
<pounds>
	1
</pounds>
<ounces>
	7.2
</ounces>
<mailtype>
	Package
</mailtype>
<country>
	CANADA
</country>
<postage>
	11.95
</postage>
<valueofcontents>
	15.40
</valueofcontents>
<inscomment>
	SERVICE
</inscomment>
<svccommitments>
	6 - 10 business days
</svccommitments>
<svcdescription>
	Priority Mail&lt;sup&gt;&amp;reg;&lt;/sup&gt; International Large Video Flat Rate Box**
</svcdescription>
<maxdimensions>
	USPS-Produced Large Video Box: 9-1/4" x 6-1/4" x 2".<br>Maximum weight 4 pounds.
</maxdimensions>
<maxweight>
	4
</maxweight>
</service>
<service id="8">
<pounds>
	1
</pounds>
<ounces>
	7.2
</ounces>
<mailtype>
	Package
</mailtype>
<country>
	CANADA
</country>
<postage>
	11.95
</postage>
<valueofcontents>
	15.40
</valueofcontents>
<inscomment>
	SERVICE
</inscomment>
<svccommitments>
	6 - 10 business days
</svccommitments>
<svcdescription>
	Priority Mail&lt;sup&gt;&amp;reg;&lt;/sup&gt; International Flat Rate Envelope**
</svcdescription>
<maxdimensions>
	USPS-Produced Envelope: 12-1/2" x 9-1/2".<br>Maximum weight 4 pounds.
</maxdimensions>
<maxweight>
	4
</maxweight>
</service>
<service id="22">
<pounds>
	1
</pounds>
<ounces>
	7.2
</ounces>
<mailtype>
	Package
</mailtype>
<country>
	CANADA
</country>
<postage>
	11.95
</postage>
<valueofcontents>
	15.40
</valueofcontents>
<inscomment>
	SERVICE
</inscomment>
<svccommitments>
	6 - 10 business days
</svccommitments>
<svcdescription>
	Priority Mail&lt;sup&gt;&amp;reg;&lt;/sup&gt; International Legal Flat Rate Envelope**
</svcdescription>
<maxdimensions>
	USPS-Produced Envelope: 15" x 9-1/2".<br>Maximum weight 4 pounds.
</maxdimensions>
<maxweight>
	4
</maxweight>
</service>
<service id="23">
<pounds>
	1
</pounds>
<ounces>
	7.2
</ounces>
<mailtype>
	Package
</mailtype>
<country>
	CANADA
</country>
<postage>
	11.95
</postage>
<valueofcontents>
	15.40
</valueofcontents>
<inscomment>
	SERVICE
</inscomment>
<svccommitments>
	6 - 10 business days
</svccommitments>
<svcdescription>
	Priority Mail&lt;sup&gt;&amp;reg;&lt;/sup&gt; International Padded Flat Rate Envelope**
</svcdescription>
<maxdimensions>
	USPS-Produced Envelope: 12-1/2" x 9-1/2".<br>Maximum weight 4 pounds.
</maxdimensions>
<maxweight>
	4
</maxweight>
</service>
<service id="18">
<pounds>
	1
</pounds>
<ounces>
	7.2
</ounces>
<mailtype>
	Package
</mailtype>
<country>
	CANADA
</country>
<postage>
	11.95
</postage>
<valueofcontents>
	15.40
</valueofcontents>
<inscomment>
	SERVICE
</inscomment>
<svccommitments>
	6 - 10 business days
</svccommitments>
<svcdescription>
	Priority Mail&lt;sup&gt;&amp;reg;&lt;/sup&gt; International Gift Card Flat Rate Envelope**
</svcdescription>
<maxdimensions>
	USPS-Produced Envelope: 10" x 7".<br>Maximum weight 4 pounds.
</maxdimensions>
<maxweight>
	4
</maxweight>
</service>
<service id="20">
<pounds>
	1
</pounds>
<ounces>
	7.2
</ounces>
<mailtype>
	Package
</mailtype>
<country>
	CANADA
</country>
<postage>
	11.95
</postage>
<valueofcontents>
	15.40
</valueofcontents>
<inscomment>
	SERVICE
</inscomment>
<svccommitments>
	6 - 10 business days
</svccommitments>
<svcdescription>
	Priority Mail&lt;sup&gt;&amp;reg;&lt;/sup&gt; International Small Flat Rate Envelope**
</svcdescription>
<maxdimensions>
	USPS-Produced Envelope: 10" x 6".<br>Maximum weight 4 pounds.
</maxdimensions>
<maxweight>
	4
</maxweight>
</service>
<service id="19">
<pounds>
	1
</pounds>
<ounces>
	7.2
</ounces>
<mailtype>
	Package
</mailtype>
<country>
	CANADA
</country>
<postage>
	11.95
</postage>
<valueofcontents>
	15.40
</valueofcontents>
<inscomment>
	SERVICE
</inscomment>
<svccommitments>
	6 - 10 business days
</svccommitments>
<svcdescription>
	Priority Mail&lt;sup&gt;&amp;reg;&lt;/sup&gt; International Window Flat Rate Envelope**
</svcdescription>
<maxdimensions>
	USPS-Produced Envelope: 10" x 5".<br>Maximum weight 4 pounds.
</maxdimensions>
<maxweight>
	4
</maxweight>
</service>
<service id="15">
<pounds>
	1
</pounds>
<ounces>
	7.2
</ounces>
<mailtype>
	Package
</mailtype>
<country>
	CANADA
</country>
<postage>
	6.97
</postage>
<valueofcontents>
	15.40
</valueofcontents>
<inscomment>
	SERVICE
</inscomment>
<svccommitments>
	Varies by country
</svccommitments>
<svcdescription>
	First-Class Mail&lt;sup&gt;&amp;reg;&lt;/sup&gt; International Package**
</svcdescription>
<maxdimensions>
	Other than rolls: Max. length 24", max length, height and depth (thickness) combined 36"<br>Rolls: Max. length 36". Max length and twice the diameter combined 42"
</maxdimensions>
<maxweight>
	4
</maxweight>
</service>
<service id="14">
<pounds>
	1
</pounds>
<ounces>
	7.2
</ounces>
<mailtype>
	Package
</mailtype>
<country>
	CANADA
</country>
<postage>
	6.77
</postage>
<valueofcontents>
	15.40
</valueofcontents>
<inscomment>
	SERVICE
</inscomment>
<svccommitments>
	Varies by country
</svccommitments>
<svcdescription>
	First-Class Mail&lt;sup&gt;&amp;reg;&lt;/sup&gt; International Large Envelope**
</svcdescription>
<maxdimensions>
	Max. length 15", height 12" or thickness 3/4"
</maxdimensions>
<maxweight>
	4
</maxweight>
</service>
</package>
</intlrateresponse>

 

Hope this will help somebody to alter the module file...

 

 

Thank you for your efforts!

Share this post


Link to post
Share on other sites

Just a note...I am using the methods module 3.02 with adjusted names from the change last year and the domestic is working perfect. It's just the international that is giving me the error.

Share this post


Link to post
Share on other sites

Same problem here!!

 

 

I am having the same issue.

 

International rates are completely broken, however, part of domestic rates are working. I am getting feed result like Media Mail<sup>&reg;</sup>, Name feed back funny looking however, rates are still there, well.... kinda off, we are still able to take domestic orders despite the name class is looking funny, BUT we just realize there is another failed issued, the handling fee set in admin for the domestic shipping is no longer working. Rate given to customers are actually as posted, it had completely ignored the handling fee set in admin. Not sure what they have done to affect that handling fee tags.

 

Aghh... I hope USPS are aware of 3 issues and will have these be fixed ASAP.

Share this post


Link to post
Share on other sites

anyone having any luck with this yet? What version of usps methods and what modifications need to be made for this to work?

Share this post


Link to post
Share on other sites

Let me please add my voice to the complaints. I got the e-mail from USPS on 12/16 and had hoped that someone had a fix prepared. It seemed obvious that the level of changes were extensive and appeared to be documented in the e-mail, including addresses to test environment APIs. Domestic shipping is working fine for me (using USPS module 2.9.6), but International is completely broken -

An error occured with the USPS shipping calculations.

If you prefer to use USPS as your shipping method, please contact the store owner.

 

Please help!

Share this post


Link to post
Share on other sites

anyone having any luck with this yet? What version of usps methods and what modifications need to be made for this to work?

 

 

PARTIAL FIX TO HAVE THE NAMES DISPLAYED CORRECTLY:

 

 

in incudes/modules/shipping/usps.php:

 

 

look for:

 

$service = preg_match('/<MailService>(.*)<\/MailService>/', $response[$i], $regs);

 

add after the code above:

 

$service = htmlspecialchars_decode($regs[1]);
$service = preg_replace('/\<sup\>\&reg;\<\/sup\>/', '<sup>®</sup>', $service);
$service = preg_replace('/Large Envelope/', '', $service);

 

That will get rid of the encoded HTML and put the correct ® trademark after the names.

 

 

BUT THIS WILL NOT FIX THE INTERNATIONAL RATES!

Edited by pixclinic

Share this post


Link to post
Share on other sites

thanks for posting the fix for the domestic shipping names. Im just wondering if there's ANYTHING that can be done aside from installing an international flat rate for now.

anyone know if oscommerce 3 having the same issue? I dont see a thread in their section.

Share this post


Link to post
Share on other sites

That change did not work for me. I am running USPS 3.0 from 2008. I do not have

$service = preg_match('/<MailService>(.*)<\/MailService>/', $response[$i], $regs);

 

But rather

 

$n = sizeof($response);
       for ($i=0; $i<$n; $i++) {
         if (strpos($response[$i], '<Rate>')) {
           $service = ereg('<MailService>(.*)</MailService>', $response[$i], $regs); 

 

 

I tried adding your code after the above, but it did not change anything.

$service = htmlspecialchars_decode($regs[1]); 
$service = preg_replace('/\<sup\>\&reg;\<\/sup\>/', '<sup>®</sup>', $service); 
$service = preg_replace('/Large Envelope/', '', $service);

 

Getting:

 

United States Postal Service   
First-Class Mail<sup>&reg;</sup> Package $1.90   
Media Mail<sup>&reg;</sup> $2.38   
Parcel Post<sup>&reg;</sup> $4.90   
Priority Mail<sup>&reg;</sup> $5.10   
Express Mail<sup>&reg;</sup> $13.25   

 

Also, USPS.php is not including the handling fee on the shipping, rather giving just the base USPS rate without the handling fee, not to mention that the international is not working. Thanks for the attempt. I hope that someone comes up with a solution to this problem soon, as we are losing most of our international business due tot hei problem.

Share this post


Link to post
Share on other sites

My quick fix for USPS domestic rates was to just strip out all the new characters on the $type variable before it builds the shipping quotes array. I have a heavily modified usps.php modules file so I cannot show you exactly where, but basically find where the quotes array is built from the USPS response and add this code:

 

Mine looks like this:

 

list($type, $cost) = each($uspsQuote[$i]);

 

so I added this after:

 

$type = str_replace('&lt;sup&gt;&amp;reg;&lt;/sup&gt;', '', $type);

$type = str_replace('&lt;sup&gt;&amp;trade;&lt;/sup&gt;', '', $type);

$type = str_replace('**', '', $type);

 

This removes the everything that was added by USPS that was causing errors on my site. It also fixes the international issue (response had added a ** to the end of the title).

 

Hope this helps!

Share this post


Link to post
Share on other sites

Thanks that worked partially. At least now it is not showing the extra characters in the description, But international is still now working. Here are the problems we still have:

 


  1.  
  2. International USPS Mail options not working

    •  
    • This is costing us business as the only rates showing are UPS Expedited and Express and Express Plus, which starts at over $89 to Europe, verus $4.80 for usps First Class mail

[*]Handling Fee not included in rate calculation

[*]Delivery time estimate not inlcuded

 

Actually we are running 4.3 Usps

/*
$Id: usps.php 3.0 2008-03-01 04:59:07Z user $
 ++++ Original contribution by Brad Waite and Fritz Clapp ++++
 ++++ incorporating USPS revisions to service names ++++
 Copyright 2008 osCommerce
 Released under the GNU General Public License
*/
//VERSION: 4.3.0 ALPHA
//LAST UPDATED: September 8th, 2008 by Greg Deeth

//Modified by Greg Deeth April 30, 2008 to use API v.3.0
//Modified by Greg Deeth May 12, 2008 for API Change
//Please refer to http://www.usps.com/webtools/_pdf/Rate-Calculators-v1-2.pdf for more information on RateV3 syntax.

 

This has to be causing a lot of sites major problems yesterday and Today. I hope someone can find a solution soon.

 

Don

Share this post


Link to post
Share on other sites

Thanks that worked partially. At least now it is not showing the extra characters in the description, But international is still now working. Here are the problems we still have:

 


  1.  
  2. International USPS Mail options not working

    •  
    • This is costing us business as the only rates showing are UPS Expedited and Express and Express Plus, which starts at over $89 to Europe, verus $4.80 for usps First Class mail

[*]Handling Fee not included in rate calculation

[*]Delivery time estimate not inlcuded

 

Actually we are running 4.3 Usps

/*
$Id: usps.php 3.0 2008-03-01 04:59:07Z user $
 ++++ Original contribution by Brad Waite and Fritz Clapp ++++
 ++++ incorporating USPS revisions to service names ++++
 Copyright 2008 osCommerce
 Released under the GNU General Public License
*/
//VERSION: 4.3.0 ALPHA
//LAST UPDATED: September 8th, 2008 by Greg Deeth

//Modified by Greg Deeth April 30, 2008 to use API v.3.0
//Modified by Greg Deeth May 12, 2008 for API Change
//Please refer to http://www.usps.com/webtools/_pdf/Rate-Calculators-v1-2.pdf for more information on RateV3 syntax.

 

This has to be causing a lot of sites major problems yesterday and Today. I hope someone can find a solution soon.

 

Don

 

Can you post your modules/shipping/usps.php file and also what is populated in the configuration table, configuration_title field "Shipping Type" and I can do a compare on what I have in mine.

Share this post


Link to post
Share on other sites

Thanks that worked partially. At least now it is not showing the extra characters in the description, But international is still now working. Here are the problems we still have:

 


  1.  
  2. International USPS Mail options not working

    •  
    • This is costing us business as the only rates showing are UPS Expedited and Express and Express Plus, which starts at over $89 to Europe, verus $4.80 for usps First Class mail

[*]Handling Fee not included in rate calculation

[*]Delivery time estimate not inlcuded

 

Actually we are running 4.3 Usps

/*
$Id: usps.php 3.0 2008-03-01 04:59:07Z user $
 ++++ Original contribution by Brad Waite and Fritz Clapp ++++
 ++++ incorporating USPS revisions to service names ++++
 Copyright 2008 osCommerce
 Released under the GNU General Public License
*/
//VERSION: 4.3.0 ALPHA
//LAST UPDATED: September 8th, 2008 by Greg Deeth

//Modified by Greg Deeth April 30, 2008 to use API v.3.0
//Modified by Greg Deeth May 12, 2008 for API Change
//Please refer to http://www.usps.com/webtools/_pdf/Rate-Calculators-v1-2.pdf for more information on RateV3 syntax.

 

This has to be causing a lot of sites major problems yesterday and Today. I hope someone can find a solution soon.

 

Don

 

 

I have the exact same version and the same issues you are getting.

 

the new API reference for the change on USPS is now located at http://www.usps.com/webtools/_pdf/Rate-Calculators-v2-3.pdf, Maybe someone here whom are highly skilled can to decode what changed USPS had impliment that had caused these Major issues.

Share this post


Link to post
Share on other sites

Hello,

 

I have USPS shipping working again. The store I work on is highly customized, so the exact code my not be applicable to others' situations. However, I wanted to describe the changes I made in case they are helpful...

 

The changes USPS made yesterday to the existing rate calculator APIs are:

 

1) Added the "registered trademark" symbol to the end of many of the Domestic and International service titles.

2) Changed the strings of many of the International services.

 

All of the changes are to source code file usps.php

 

To address number 1, I strip out the botched trademark code like this:

 

$service = str_replace('&lt;sup&gt;&amp;reg;&lt;/sup&gt;', "", $service);

 

for both Domestic and International responses.

 

To Address number 2, I made these changes to change my existing service name strings to the new ones:

 

Change

First-Class Mail International Package

to

First-Class Mail International Package**

 

Change

Express Mail International (EMS)

to

Express Mail International

 

Hope this helps someone!

 

pebr

Share this post


Link to post
Share on other sites

This might also help. Since the titles have changed for some of the shipping class types you have to be sure that what you have populated in your Configuration table > configuration_title = Shipping Methods record matches what USPS sends in their response.

 

Using my code poste earlier the stripped response for domestic services looks like this now:

 

Express Mail

Express Mail Sunday/Holiday Delivery

Express Mail Flat Rate Envelope

Express Mail Sunday/Holiday Delivery Flat Rate Envelope

Express Mail Legal Flat Rate Envelope

Express Mail Sunday/Holiday Delivery Legal Flat Rate Envelope

Priority Mail

Priority Mail Large Flat Rate Box

Priority Mail Medium Flat Rate Box

Priority Mail Small Flat Rate Box

Priority Mail Flat Rate Envelope

Priority Mail Legal Flat Rate Envelope

Priority Mail Padded Flat Rate Envelope

Priority Mail Gift Card Flat Rate Envelope

Priority Mail Small Flat Rate Envelope

Priority Mail Window Flat Rate Envelope

Parcel Post

Media Mail

Library Mail

 

And for International (Canada was my test country):

 

Global Express Guaranteed (GXG)

Global Express Guaranteed Non-Document Rectangular

USPS GXG Envelopes

Express Mail International

Express Mail International Flat Rate Envelope

Express Mail International Legal Flat Rate Envelope

Priority Mail International

Priority Mail International Flat Rate Envelope

Priority Mail International Legal Flat Rate Envelope

Priority Mail International Padded Flat Rate Envelope

Priority Mail International Gift Card Flat Rate Envelope

Priority Mail International Small Flat Rate Envelope

Priority Mail International Window Flat Rate Envelope

First-Class Mail International Package

First-Class Mail International Large Envelope

 

If these service names do not match what you have populated in the configuration_title = Shipping Methods record then these services will not display. Be sure you update both the configuration_value & set_function with the updated service names.

Edited by grapesmuggler

Share this post


Link to post
Share on other sites

OK, I have domestic working well, and international 'tamed' a bit - finally got the descriptions cleaned up thanks to tips here, but in the version of usps.php that we are using, the services are not controlled in the admin, but rather they are/were controlled by commenting out elements in an array. Example, if I didn't want customers to see Priority Mail for domestic, I'd comment it out:

 

// 'PRIORITY' => 'Priority Mail'),

 

That also used to work for international types via the array "intl_types". But even if i comment that out, ALL options are displaying for international now... so, well, i hacked this to limit the options. (basically it uses the $skip_array elements to identify keywords in services you don't want to show up to the customer).

 

$size = sizeof($services);
for ($i=0, $n=$size; $i<$n; $i++) {
$skipit = 0;
if (strpos($services[$i], '<Postage>')) {
	$service = ereg('<SvcDescription>(.*)</SvcDescription>', $services[$i], $regs);
	$service = $regs[1];

	$skip_array = array('Rectangular','Envelope','Flat Rate','Legal','GXG');

	foreach ($skip_array as $value) {
		if (strstr($service, $value)) {
			$skipit=1;
		} 
	}

	$service = str_replace('&lt;sup&gt;&amp;reg;&lt;/sup&gt;', '', $service);
	$service = str_replace('&lt;sup&gt;&amp;trade;&lt;/sup&gt;', '', $service);

	$postage = ereg('<Postage>(.*)</Postage>', $services[$i], $regs);
	$postage = $regs[1];

	if (isset($this->service) && ($service != $this->service) ) {
		continue;
	}

	if ($skipit !== 1) {
		$rates[] = array($service => $postage);
	}

}
}

 

It's still a band-aid until someone revamps the contribution, but it got us up and running...

 

Thanks all!

 

Jim

Share this post


Link to post
Share on other sites

Here is my usps.php in /includes/modules/shipping:

 

<?php
/*
$Id: usps.php 3.0 2008-03-01 04:59:07Z user $
 ++++ Original contribution by Brad Waite and Fritz Clapp ++++
 ++++ incorporating USPS revisions to service names ++++
 Copyright 2008 osCommerce
 Released under the GNU General Public License
*/
//VERSION: 4.3.0 ALPHA
//LAST UPDATED: September 8th, 2008 by Greg Deeth

//Modified by Greg Deeth April 30, 2008 to use API v.3.0
//Modified by Greg Deeth May 12, 2008 for API Change
//Please refer to http://www.usps.com/webtools/_pdf/Rate-Calculators-v1-2.pdf for more information on RateV3 syntax.


 class usps {
   var $code, $title, $description, $icon, $enabled, $countries;

// class constructor
   function usps() {
     global $order;

     $this->code = 'usps';
     $this->title = MODULE_SHIPPING_USPS_TEXT_TITLE;
     $this->description = MODULE_SHIPPING_USPS_TEXT_DESCRIPTION;
     $this->sort_order = MODULE_SHIPPING_USPS_SORT_ORDER;
     $this->icon = DIR_WS_ICONS . 'shipping_usps.gif';
     $this->tax_class = MODULE_SHIPPING_USPS_TAX_CLASS;
     $this->enabled = ((MODULE_SHIPPING_USPS_STATUS == 'True') ? true : false);
       $this->GlobalTest;

     if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_USPS_ZONE > 0) ) {
       $check_flag = false;
       $check_query = tep_db_query("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_SHIPPING_USPS_ZONE . "' and zone_country_id = '" . $order->delivery['country']['id'] . "' order by zone_id");
       while ($check = tep_db_fetch_array($check_query)) {
         if ($check['zone_id'] < 1) {
           $check_flag = true;
           break;
         } elseif ($check['zone_id'] == $order->delivery['zone_id']) {
           $check_flag = true;
           break;
         }
       }

       if ($check_flag == false) {
         $this->enabled = false;
       }
     }

       $this->handling = explode( ", ", MODULE_SHIPPING_USPS_HANDLING_DOMESTIC);
       //Listed in the order below:
     $this->types = array('Express Mail' => 'Express Mail',
                                                  'Priority Mail' => 'Priority Mail',
                                                  'Priority Mail Flat-Rate Envelope' => 'Priority Mail Flat-Rate Envelope',
                                                  'Priority Mail Flat-Rate Box' => 'Priority Mail Flat-Rate Box',
                                                  'First-Class Mail' => 'First Class Mail',
                                                  'Parcel Post' => 'Parcel Post',
                                                  'Bound Printed Matter' => 'Bound Printed Matter',
                                                  'Media Mail' => 'Media Mail');


       /******************************************************************* */
       //Added by Greg Deeth on May 12th, 2008
       //INTERNATIONAL MAIL OPTIONS
       //Change the values to the option you would like

       //FIRST CLASS MAIL INTERNATIONAL OPTION:
               $this->FirstClassIntType = 'Letters';                                  //OPTIONS: 'Letters', 'Large Envelope', 'Package'

       //PRIORITY FLAT-RATE BOX INTERNATIONAL OPTION:
               $this->PriorityFlatRateBoxType = 'Flat-Rate Box';                  //OPTIONS: 'Flat-Rate Box', 'Large Flat-Rate Box'
       /****************************************************************** */


     $this->intl_types = array('GLBL EX' => 'Global Express Guaranteed',
                                                               'GLBL EX NONDOC RECT' => 'Global Express Guaranteed Non-Document Rectangular',
                                                               'GLBL EX NONDOC NON-RECT' => 'Global Express Guaranteed Non-Document Non-Rectangular',
                                                               'EXPRESS INT' => 'Express Mail International (EMS)',
                                                               'EXPRESS INT FLAT RATE ENV' => 'Express Mail International (EMS) Flat-Rate Envelope',
                                                               'PRIORITY INT' => 'Priority Mail International',
                                                               'PRIORITY INT FLAT RATE ENV' => 'Priority Mail International Flat-Rate Envelope',
                                                               'PRIORITY INT FLAT RATE BOX' => 'Priority Mail International ' . $this->PriorityFlatRateBoxType,
                                                               'FIRST-CLASS INT' => 'First Class Mail International ' . $this->FirstClassIntType);


     $this->countries = $this->country_list();
       $this->countryinsure = $this->country_maxinsure();
   }

// class methods
   function quote($method = '') {
     global $order, $shipping_weight, $shipping_num_boxes, $transittime;

     if ( tep_not_null($method) && (isset($this->types[$method]) || in_array($method, explode(', ',MODULE_SHIPPING_USPS_TYPES_INTL))) ) {
       $this->_setService($method);
     }

//BEGIN INSURANCE MODULE by Kevin Shelton
       // divide the value of the order among the packages based on the order total or subtotal depending on whether or not you have configured to insure tax
       if (MODULE_SHIPPING_USPS_INSURE_TAX == 'True') {
                 $costperpkg = $order->info['total'] / $shipping_num_boxes;
       }
       else {
                 $costperpkg = $order->info['subtotal'] / $shipping_num_boxes;
       }

       // retrieve the maximum allowed insurance for the destination country and if the package value exceeds it then set package value to the maximum allowed
       $maxins = $this->countryinsure[$order->delivery['country']['iso_code_2']];
       if ($costperpkg > $maxins) $costperpkg = $maxins;

       // if insurance not allowed for destination or insurance is turned off add nothing to shipping cost
       if (($maxins == 0) || (MODULE_SHIPPING_USPS_INSURE == 'False')) {
                 $insurance = 0;
       }

       // US and Canada share the same insurance calculation (though not the same maximum)
       else if (($order->delivery['country']['iso_code_2'] == 'US') || ($order->delivery['country']['iso_code_2'] == 'CA')){
               if ($costperpkg<=50) {
                       $insurance=MODULE_SHIPPING_USPS_INS1;
               }
               else if ($costperpkg<=100) {
                       $insurance=MODULE_SHIPPING_USPS_INS2;
               }
               else if ($costperpkg<=200) {
                       $insurance=MODULE_SHIPPING_USPS_INS3;
               }
               else if ($costperpkg<=300) {
                       $insurance=MODULE_SHIPPING_USPS_INS4;
               }
               else {
                       $insurance = MODULE_SHIPPING_USPS_INS4 + ((ceil($costperpkg/100) -3) * MODULE_SHIPPING_USPS_INS5);
               }
         }

       // if insurance allowed and is not US or Canada then calculate international insurance
       else {
               if ($costperpkg<=50) {
                           $insurance=MODULE_SHIPPING_USPS_INS6;
               }
               else if ($costperpkg<=100) {
                           $insurance=MODULE_SHIPPING_USPS_INS7;
               }
                 else if ($costperpkg<=200) {
                           $insurance=MODULE_SHIPPING_USPS_INS8;
               }
                 else if ($costperpkg<=300) {
                           $insurance=MODULE_SHIPPING_USPS_INS9;
               }
               else {
                           $insurance = MODULE_SHIPPING_USPS_INS9 + ((ceil($costperpkg/100) - 3) * MODULE_SHIPPING_USPS_INS10);
               }
       }
//END INSURANCE MODULE

       // usps doesn't accept zero weight
       // Modified by Greg Deeth on May 27th 2008
       //$shipping_weight = $shipping_weight - .15;
       if ($shipping_weight <= 0) {$shipping_weight = 0;}  //This will cause an error if the seller forgets to assign a weight for the product. This keeps buyers from having cheap shipping by accident.
     $shipping_weight = ($shipping_weight < 0.0625 ? 0.0625 : $shipping_weight);
     $shipping_pounds = floor ($shipping_weight);
     $shipping_ounces = tep_round_up((16 * ($shipping_weight - floor($shipping_weight))), 2);
     $this->_setWeight($shipping_pounds, $shipping_ounces, $shipping_weight);
       // Added by Kevin Chen (kkchen@uci.edu); Fixes the Parcel Post Bug July 1, 2004
       // Refer to http://www.usps.com/webtools/htm/Domestic-Rates.htm documentation
       // Thanks Ryan
       // End Kevin Chen July 1, 2004
     /*
       THE FOLLOWING FUNCTION CAUSES A 500 ERROR WHEN USING PAYPAL EXPRESS
       function round_up($valueIn, $places=0) {
               if ($places < 0) { $places = 0; }
               $mult = pow(10, $places);
               return (ceil($valueIn * $mult) / $mult);
           }
       */
     if (in_array('Display weight', explode(', ', MODULE_SHIPPING_USPS_OPTIONS))) {
                 $shiptitle = ' (' . $shipping_num_boxes . ' x ' . tep_round_up($shipping_weight, 2) . 'lbs)' . ' (' . $shipping_pounds . 'lbs, ' . $shipping_ounces . 'oz)';
     } else {
       $shiptitle = '';
     }

     $uspsQuote = $this->_getQuote();

     if (is_array($uspsQuote)) {
       if (isset($uspsQuote['error'])) {
         $this->quotes = array('module' => $this->title,
                               'error' => $uspsQuote['error']);
       } else {
         $this->quotes = array('id' => $this->code,
                               'module' => $this->title . $shiptitle);

         $methods = array();
         $size = sizeof($uspsQuote);
         for ($i=0; $i<$size; $i++) {
           list($type, $cost) = each($uspsQuote[$i]);
//added 1-3-11
$type = str_replace('&lt;sup&gt;&amp;reg;&lt;/sup&gt;', '', $type);
$type = str_replace('&lt;sup&gt;&amp;trade;&lt;/sup&gt;', '', $type);
$type = str_replace('**', '', $type);
// end added 1-3-11

           $title = ((isset($this->types[$type])) ? $this->types[$type] : $type);
           if(in_array('Display transit time', explode(', ', MODULE_SHIPPING_USPS_OPTIONS)))    $title .= $transittime[$type];


                       if (MODULE_SHIPPING_DMSTC_INSURANCE_OPTION == 'Force Insurance') {
                               $methods[] = array('id' => $type,
                               'title' => $title,
                               'cost' => ($cost + $insurance + $handling_cost[0]) * $shipping_num_boxes);
                       }
                        else {
                               $methods[] = array('id' => $type,
                                      'title' => $title,
                                       'cost' => ($cost + $handling_cost[0]) * $shipping_num_boxes);
                       }
         }

         $this->quotes['methods'] = $methods;

         if ($this->tax_class > 0) {
           $this->quotes['tax'] = tep_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
         }
       }
     } else {
       $this->quotes = array('module' => $this->title,
                             'error' => MODULE_SHIPPING_USPS_TEXT_ERROR);
     }

     if (tep_not_null($this->icon)) $this->quotes['icon'] = tep_image($this->icon, $this->title);

     return $this->quotes;

   }

   function check() {
     if (!isset($this->_check)) {
       $check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_SHIPPING_USPS_STATUS'");
       $this->_check = tep_db_num_rows($check_query);
     }
     return $this->_check;
   }

   function install() {
     tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable USPS Shipping', 'MODULE_SHIPPING_USPS_STATUS', 'True', 'Do you want to offer USPS shipping?', '6', '0', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())");
     tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enter the USPS User ID', 'MODULE_SHIPPING_USPS_USERID', 'NONE, NONE', 'Enter the USPS USERID assigned to you. <u>You must contact USPS to have them switch you to the Production server.</u>  Otherwise this module will not work!', '6', '0', 'tep_cfg_multiinput_list(array(\'ID\', \'Password\'), ', now())");
     tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Domestic Handling Fees', 'MODULE_SHIPPING_USPS_HANDLING_DOMESTIC', '0, 0, 0, 0, 0, 0, 0, 0', 'Add a different handling fee for each shipping type.', '6', '0', 'tep_cfg_multiinput_list(array(\'Express Mail\', \'Priority Std\', \'Priority FltRt Env\', \'Priority FltRt Box\', \'FirstClass\', \'Parcel Post\', \'BoundPM\', \'Media Mail\'), ', now())");
     tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Which server to use', 'MODULE_SHIPPING_USPS_SERVER', 'production', 'An account at USPS is needed to use the Production server', '6', '0', 'tep_cfg_select_option(array(\'test\', \'production\'), ', now())");
     tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Tax Class', 'MODULE_SHIPPING_USPS_TAX_CLASS', '0', 'Use the following tax class on the shipping fee.', '6', '0', 'tep_get_tax_class_title', 'tep_cfg_pull_down_tax_classes(', now())");
     tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Shipping Zone', 'MODULE_SHIPPING_USPS_ZONE', '0', 'If a zone is selected, only enable this shipping method for that zone.', '6', '0', 'tep_get_zone_class_title', 'tep_cfg_pull_down_zone_classes(', now())");
     tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_SHIPPING_USPS_SORT_ORDER', '0', 'Sort order of display.', '6', '0', now())");
     tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Domestic Shipping Methods', 'MODULE_SHIPPING_USPS_TYPES', 'Express Mail, Priority Mail, Priority Mail Flat-Rate Envelope, Priority Mail Flat-Rate Box, First-Class Mail, Parcel Post, Bound Printed Matter, Media Mail', 'Select the domestic services to be offered:', '6', '0', 'tep_cfg_select_multioption(array(\'Express Mail\', \'Priority Mail\', \'Priority Mail Flat-Rate Envelope\', \'Priority Mail Flat-Rate Box\', \'First-Class Mail\', \'Parcel Post\',\'Bound Printed Matter\',\'Media Mail\'), ', now())");
       tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Domstic First-Class Threshold', 'MODULE_SHIPPING_CONFIG_DMSTC_FIRSTCLASS_THRESHOLD', '0, 3.5, 3.5, 10, 10, 13, 0, 13', 'If the total weight is between 0oz and 3.5oz, Letter is used. Over 3.5oz, Flat is used, etc. ONLY ONE TYPE IS USED!<br><br><i><u>Maximums:</u><br>Letters <u><</u> 3.5oz<br>Flats (large envelopes) <u><</u> 13oz<br>Parcels (packages) <u><</u> 13oz</i>', '6', '0', 'tep_cfg_multiinput_duallist_oz(array(\'Letter\', \'Flat\', \'Parcel\', \'MACHINABLE True\'), ', now())");
       tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Domstic Priority Mail Threshold', 'MODULE_SHIPPING_CONFIG_DMSTC_PRIORITY_THRESHOLD', '0, 70, 0, 70, 0, 70', 'If the total weight is between 0lb and 2lbs, Standard is used. Between 1lb and 3lbs, Flat-Rate is used, etc. TYPES CONTROLLED SEPARATELY, ALL USED.  <br><br><i>All Priority types have a weight limit of 70lbs.</i>', '6', '0', 'tep_cfg_multiinput_duallist_lb(array(\'Flat-Rate Envelope\', \'Flat-Rate Box\', \'Standard Priority\'), ', now())");
       tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Domstic Other Mail Threshold', 'MODULE_SHIPPING_CONFIG_DMSTC_OTHER_THRESHOLD', '0, 0, 0, 70, 0, 70, 0, 0, 0, 0, 0, 70, 0, 70', 'Epress FltRt and Standard cannot be used at same time. ParcelPst Reg, Lrg, OvrSz cannot be used same time. All others are controlled separately.<br><br><i>BPM limit 15lbs. All others is 70lbs</i>', '6', '0', 'tep_cfg_multiinput_duallist_lb(array(\'Express FltRt Env\', \'Express Standard\', \'Parcel Pst Reg\', \'Parcel Pst Lrg\', \'Parcel Pst OvrSz\', \'BoundPM\', \'Media Mail\'), ', now())");

//You can add Global Express services here, but be aware that if this line below is too long, 
//it will create an install error.  
//If this line is changed, you must uninstall and reinstall this module for the changes to take effect.
     //tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Int\'l Shipping Methods', 'MODULE_SHIPPING_USPS_TYPES_INTL', 'GLBL EX, GLBL EX NONDOC RECT, GLBL EX NONDOC NON-RECT, EXPRESS INT, EXPRESS INT FLAT RATE ENV, PRIORITY INT, PRIORITY INT FLAT RATE ENV, PRIORITY INT FLAT RATE BOX, FIRST-CLASS INT', 'Select the international services to be offered:', '6', '0', 'tep_cfg_select_multioption(array(\'GLBL EX\', \'GLBL EX NONDOC RECT\', \'GLBL EX NONDOC NON-RECT\', \'EXPRESS INT\', \'EXPRESS INT FLAT RATE ENV\', \'PRIORITY INT\', \'PRIORITY INT FLAT RATE ENV\', \'PRIORITY INT FLAT RATE BOX\', \'FIRST-CLASS INT\'), ', now())");

     tep_db_query("insert into " . TABLE_CONFIGURATION . "  (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Int\'l Shipping Methods', 'MODULE_SHIPPING_USPS_TYPES_INTL', '', 'Select the international services to be offered:', '6', '15', 'tep_cfg_select_multioption(array(\'Global Express Guaranteed (GXG)\', \'Global Express Guaranteed Non-Document Rectangular\', \'Global Express Guaranteed Non-Document Non-Rectangular\',\'USPS GXG Envelopes\', \'Express Mail International\', \'Express Mail International Flat Rate Envelope\', \'Priority Mail International\', \'Priority Mail International Large Flat Rate Box\',\'Priority Mail International Medium Flat Rate Box\',\'Priority Mail International Small Flat Rate Box\',\'Priority Mail International Flat Rate Envelope\', \'First-Class Mail International Package\', \'First-Class Mail International Large Envelope\'), ',  now())");

     tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('USPS Options', 'MODULE_SHIPPING_USPS_OPTIONS', 'Display weight, Display transit time', 'Select from the following the USPS options.', '6', '0', 'tep_cfg_select_multioption(array(\'Display weight\', \'Display transit time\'), ', now())");
     tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Domestic Insurance Options', 'MODULE_SHIPPING_DMSTC_INSURANCE_OPTION', 'None', 'Select how you want to offer USPS Domestic Insurance.', '6', '0', 'tep_cfg_select_option(array(\'None\', \'Buyers Option Does not work yet\', \'Force Insurance\'), ', now())");
       tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('International Insurance Options', 'MODULE_SHIPPING_INTL_INSURANCE_OPTION', 'None', 'Select how you want to offer USPS International Insurance.  International Insurance is calculated automatically by USPS for certain mailing types.', '6', '0', 'tep_cfg_select_option(array(\'None\', \'Buyers Option Does not work yet\', \'Force Insurance\'), ', now())");

//configuration values for insurance
     tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, date_added) values ('US/Canada $.01-$50.00', 'MODULE_SHIPPING_USPS_INS1', '1.75', 'US/Canada insurance for totals $.01-$50.00', '6', '0', 'currencies->format', now())");
     tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, date_added) values ('US/Canada $50.01-$100.00', 'MODULE_SHIPPING_USPS_INS2', '2.25', 'US/Canada insurance for totals $50.01-$100', '6', '0', 'currencies->format', now())");
     tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, date_added) values ('US/Canada $100.01-$200.00', 'MODULE_SHIPPING_USPS_INS3', '2.75', 'US/Canada insurance for totals $100.01-$200', '6', '0', 'currencies->format', now())");
     tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, date_added) values ('US/Canada $200.01-$300.00', 'MODULE_SHIPPING_USPS_INS4', '4.70', 'US/Canada insurance for totals $200.01-$300', '6', '0', 'currencies->format', now())");
     tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, date_added) values ('US/Canada per $100 over $300', 'MODULE_SHIPPING_USPS_INS5', '1.00', 'US/Canada insurance for every $100 over $300 (add)', '6', '0', 'currencies->format', now())");

     /*tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, date_added) values ('International $.01-$50.00', 'MODULE_SHIPPING_USPS_INS6', '2.40', 'International insurance for totals $.01-$50.00', '6', '0', 'currencies->format', now())");
     tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, date_added) values ('International $50.01-$100.00', 'MODULE_SHIPPING_USPS_INS7', '3.30', 'International insurance for totals $50.01-$100', '6', '0', 'currencies->format', now())");
     tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, date_added) values ('International $100.01-$200.00', 'MODULE_SHIPPING_USPS_INS8', '4.20', 'International insurance for totals $100.01-$200', '6', '0', 'currencies->format', now())");
     tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, date_added) values ('International $200.01-$300.00', 'MODULE_SHIPPING_USPS_INS9', '5.10', 'International insurance for totals $200.01-$300', '6', '0', 'currencies->format', now())");
     tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, date_added) values ('International per $100 over $300', 'MODULE_SHIPPING_USPS_INS10', '.90', 'International insurance for every $100 over $300 (add)', '6', '0', 'currencies->format', now())");*/
     //tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Insure Packages', 'MODULE_SHIPPING_USPS_INSURE', 'True', 'Insure packages shipped by USPS?', '6', '0', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())");
     tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Insure Tax', 'MODULE_SHIPPING_USPS_INSURE_TAX', 'True', 'Insure tax on packages shipped by USPS?', '6', '0', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())");
   }

   function remove() {
     tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");
   }

   function keys() {
     return array('MODULE_SHIPPING_USPS_STATUS', 'MODULE_SHIPPING_USPS_USERID', 'MODULE_SHIPPING_USPS_HANDLING_DOMESTIC', 'MODULE_SHIPPING_USPS_SERVER', 'MODULE_SHIPPING_USPS_TAX_CLASS', 'MODULE_SHIPPING_USPS_ZONE', 'MODULE_SHIPPING_USPS_SORT_ORDER', 'MODULE_SHIPPING_USPS_OPTIONS', 'MODULE_SHIPPING_DMSTC_INSURANCE_OPTION', 'MODULE_SHIPPING_INTL_INSURANCE_OPTION', 'MODULE_SHIPPING_USPS_TYPES', 'MODULE_SHIPPING_CONFIG_DMSTC_FIRSTCLASS_THRESHOLD', 'MODULE_SHIPPING_CONFIG_DMSTC_PRIORITY_THRESHOLD', 'MODULE_SHIPPING_CONFIG_DMSTC_OTHER_THRESHOLD', 'MODULE_SHIPPING_USPS_TYPES_INTL', 'MODULE_SHIPPING_USPS_INS1', 'MODULE_SHIPPING_USPS_INS2', 'MODULE_SHIPPING_USPS_INS3','MODULE_SHIPPING_USPS_INS4', 'MODULE_SHIPPING_USPS_INS5', /*'MODULE_SHIPPING_USPS_INS6', 'MODULE_SHIPPING_USPS_INS7', 'MODULE_SHIPPING_USPS_INS8', 'MODULE_SHIPPING_USPS_INS9', 'MODULE_SHIPPING_USPS_INS10', 'MODULE_SHIPPING_USPS_INSURE', */'MODULE_SHIPPING_USPS_INSURE_TAX');
   }

   function _setService($service) {
     $this->service = $service;
   }

   function _setWeight($pounds, $ounces=0, $weight) {
     $this->pounds = $pounds;
     $this->ounces = $ounces;
       $this->weight = $weight;
   }
/*
   function _setContainer($container) {
     $this->container = $container;
   }

   function _setSize($size) {
     $this->size = $size;
   }
*/
   function _setMachinable($machinable) {
     $this->machinable = $machinable;
   }

   function _getQuote() {
     global $order, $transittime;

     $transit = (in_array('Display transit time', explode(', ', MODULE_SHIPPING_USPS_OPTIONS)));

//RateRequest changed to RateV3Request by Greg Deeth April 30, 2008
           $Authentication = explode( ", ", MODULE_SHIPPING_USPS_USERID);  //0=>USERID, 1=>PASSWORD
     if ($order->delivery['country']['id'] == SHIPPING_ORIGIN_COUNTRY) {
       $request  = '<RateV3Request USERID="' . $Authentication[0] . '" PASSWORD="' . $Authentication[1] . '">';
       $services_count = 0;

       if (isset($this->service)) {
         $this->types = array($this->service => $this->types[$this->service]);
       }

       $dest_zip = str_replace(' ', '', $order->delivery['postcode']);
       if ($order->delivery['country']['iso_code_2'] == 'US') $dest_zip = substr($dest_zip, 0, 5);

       reset($this->types);
       $allowed_types = explode(", ", MODULE_SHIPPING_USPS_TYPES);

       while (list($key, $value) = each($this->types)) {

         if ( !in_array($key, $allowed_types) ) continue;

/********************************************************************** */
//DOMESTIC MAIL OPTIONS
//For Options list, go to page 9 of document: http://www.usps.com/webtools/_pdf/Rate-Calculators-v1-2.pdf

               //$this->size ='Regular'  //Set default value of Regular unless different value is applied below

//FIRST CLASS MAIL OPTIONS
               if ($key == 'First-Class Mail'){
                       //WEIGHT THRESHOLD OPTIONS (LETTER is changed to FLAT automatically by USPS when over 3.5oz)

                       $FCT = explode(", ", MODULE_SHIPPING_CONFIG_DMSTC_FIRSTCLASS_THRESHOLD);
                       //0=>letter, 1=>letter, 2=>flat, 3=>flat, 4=>parcel, 5=>parcel, 6=>machinable, 7=>machinable

                       if($this->pounds == 0) {
                               if($FCT[0] < $this->ounces && $this->ounces <= $FCT[1]) {
                                          $this->FirstClassMailType = 'LETTER';
                               } else if($FCT[2] < $this->ounces && $this->ounces <= $FCT[3]) {
                                     $this->FirstClassMailType = 'FLAT';
                                  } else if($FCT[4] < $this->ounces && $this->ounces <= $FCT[5]) {
                                       $this->FirstClassMailType = 'PARCEL';
                               } else {
                                       $key = 'none';
                               }

                               if($FCT[6] < $this->ounces && $this->ounces <= $FCT[7]) {
                                       $this->machinable = 'true';
                               } else {
                                       $this->machinable = 'false';
                               }
                       }
               }

//PRIORITY MAIL OPTIONS
               $PT = explode(", ", MODULE_SHIPPING_CONFIG_DMSTC_PRIORITY_THRESHOLD);
               //0=>FltRt Env, 1=>FltRt Env, 2=>FltRt Box, 3=>FltRt Box, 4=>standard, 5=>standard
       //STANDARD
               if ($key == 'Priority Mail'){
                       if ($PT[4] < $this->weight && $this->weight <= $PT[5]) {
                               $this->container = '';                                 //OPTIONS: '', 'FLAT RATE BOX', 'FLAT RATE ENVELOPE'
                               $this->size = 'REGULAR';
                       } else {
                               $key = 'none';
                       }
               }
       //ENVELOPE
               if ($key == 'Priority Mail Flat-Rate Envelope'){
                       if ($PT[0] < $this->weight && $this->weight <= $PT[1]) {
                               $key = 'Priority'; //DO NOT CHANGE
                               $this->container = 'FLAT RATE ENVELOPE';              //OPTIONS: 'FLAT RATE ENVELOPE', 'FLAT RATE BOX'
                               $this->size = 'REGULAR';
                       } else {
                               $key = 'none';
                       }
               }
       //BOX
               if ($key == 'Priority Mail Flat-Rate Box'){
                       if ($PT[2] < $this->weight && $this->weight <= $PT[3]) {
                               $key = 'Priority'; //DO NOT CHANGE
                               $this->container = 'FLAT RATE BOX';                   //OPTIONS: 'FLAT RATE BOX', 'FLAT RATE ENVELOPE'
                               $this->size = 'REGULAR';
                       } else {
                               $key = 'none';
                       }
               }

//ALL OTHER THRESHOLDS
$AOT = explode( ", ", MODULE_SHIPPING_CONFIG_DMSTC_OTHER_THRESHOLD);
//0-1=>ExpressFltRt, 2-3=>Express std, 4-5=>Parcel Pst Reg, 6-7=>Parcel Pst Lrg, 8-9=>Parcel Pst OvrSz, 10-11=>BoundPM, 12-13=>Media Mail
//EXPRESS MAIL OPTIONS
               if ($key == 'Express Mail'){
                       if ($AOT[0] < $this->weight && $this->weight <= $AOT[1]) {
                               $this->container = 'FLAT RATE ENVELOPE';
                               $this->size = 'REGULAR';  //OPTIONS: 'REGULAR', 'LARGE'
                       } elseif ($AOT[2] < $this->weight && $this->weight <= $AOT[3]) {
                               $this->container = '';
                               $this->size = 'REGULAR';  //OPTIONS: 'REGULAR', 'LARGE'
                       } else {
                               $key = 'none';
                       }
               }

//PARCEL POST OPTIONS
               if ($key == 'Parcel Post'){
                       //WEIGHT THRESHOLD OPTIONS (DEFAULT MACHINABLE: WEIGHT<70lbs WEIGHT CANNOT EXCEED 70lbs ANYWAY)
                       if ($AOT[4] < $this->weight && $this->weight <= $AOT[5]){
                             $this->machinable = 'true';        //OPTIONS: 'true', 'false'
                               $this->size = 'REGULAR';
                       } elseif ($AOT[6] < $this->weight && $this->weight <= $AOT[7]){
                             $this->machinable = 'true';        //OPTIONS: 'true', 'false'
                               $this->size = 'LARGE';
                     } elseif ($AOT[8] < $this->weight && $this->weight <= $AOT[9]){
                             $this->machinable = 'true';        //OPTIONS: 'true', 'false'
                               $this->size = 'OVERSIZE';
                       } else {
                               $key = 'none';
                       }
               }

//BPM OPTIONS
               if ($key == 'Bound Printed Matter'){
                       if ($AOT[10] < $this->weight && $this->weight <= $AOT[11]){
                               $this->size = 'REGULAR';        //OPTIONS: 'REGULAR', 'LARGE'
                       } else {
                               $key = 'none';
                       }
               }

//MEDIA MAIL OPTIONS
               if ($key == 'Media Mail'){
                       if ($AOT[12] < $this->weight && $this->weight <= $AOT[13]){
                             $this->size = 'REGULAR';        //OPTIONS: 'REGULAR, 'LARGE'
                       } else {
                               $key = 'none';
                       }
               }

//LIBRARY MAIL OPTIONS

/*************************************************************************** */

         $request .= '<Package ID="' . $services_count . '">' .
                     '<Service>' . $key . '</Service>' .
                           '<FirstClassMailType>' . $this->FirstClassMailType . '</FirstClassMailType>' .
                     '<ZipOrigination>' . SHIPPING_ORIGIN_ZIP . '</ZipOrigination>' .
                     '<ZipDestination>' . $dest_zip . '</ZipDestination>' .
                     '<Pounds>' . $this->pounds . '</Pounds>' .
                     '<Ounces>' . $this->ounces . '</Ounces>' .
                     '<Container>' . $this->container . '</Container>' .
                     '<Size>' . $this->size . '</Size>' .
                     '<Machinable>' . $this->machinable . '</Machinable>' .
                           //'<ValueOfContents>' . $order->info['total'] . '</ValueOfContents>' .
                           '</Package>';

         if($transit){
           $transitreq  = 'USERID="' . $Authentication[0] .
                        '" PASSWORD="' . $Authentication[1] . '">' .
                        '<OriginZip>' . SHIPPING_ORIGIN_ZIP . '</OriginZip>' .
                        '<DestinationZip>' . $dest_zip . '</DestinationZip>';

           switch ($key) {
             case 'Express Mail':  $transreq[$key] = 'API=ExpressMail&XML=' .
                              urlencode( '<ExpressMailRequest ' . $transitreq . '</ExpressMailRequest>');
                              break;
             case 'Priority Mail': $transreq[$key] = 'API=PriorityMail&XML=' .
                              urlencode( '<PriorityMailRequest ' . $transitreq . '</PriorityMailRequest>');
                                        if ($this->container == 'FLAT RATE ENVELOPE') {
                                               $key = 'Priority Mail Flat-Rate Envelope';
                                        }
                                        elseif ($this->container == 'FLAT RATE BOX') {
                                               $key = 'Priority Mail Flat-Rate Box';
                                        }
                              break;
             case 'Parcel Post':   $transreq[$key] = 'API=StandardB&XML=' .
                              urlencode( '<StandardBRequest ' . $transitreq . '</StandardBRequest>');
                              break;
             default:         $transreq[$key] = '';
                              break;
           }
         }


         $services_count++;
       }
       $request .= '</RateV3Request>'; //'</RateRequest>'; //Changed by Greg Deeth April 30, 2008

       $request = 'API=RateV3&XML=' . urlencode($request);
     } else {
       $request  = '<IntlRateRequest USERID="' . $Authentication[0] . '" PASSWORD="' . $Authentication[1] . '">' .
                   '<Package ID="0">' .
                   '<Pounds>' . $this->pounds . '</Pounds>' .
                   '<Ounces>' . $this->ounces . '</Ounces>' .
                   '<MailType>Package</MailType>' .
                         '<ValueOfContents>' . $order->info['total'] . '</ValueOfContents>' .
                   '<Country>' . $this->countries[$order->delivery['country']['iso_code_2']] . '</Country>' .
                   '</Package>' .
                   '</IntlRateRequest>';

       $request = 'API=IntlRate&XML=' . urlencode($request);
     }



     switch (MODULE_SHIPPING_USPS_SERVER) {
       case 'production': $usps_server = 'production.shippingapis.com'; //'stg-production.shippingapis.com'; // or  stg-secure.shippingapis.com //'production.shippingapis.com';
                          $api_dll = 'shippingapi.dll'; //'shippingapi.dll';
                          break;
       case 'test':
       default:           $usps_server = 'testing.shippingapis.com';
                          $api_dll = 'ShippingAPITest.dll';
                          break;
     }

     $body = '';

     if (!class_exists('httpClient')) {
       include('includes/classes/http_client.php');
     }

     $http = new httpClient();
     if ($http->Connect($usps_server, 80)) {
       $http->addHeader('Host', $usps_server);
       $http->addHeader('User-Agent', 'osCommerce');
       $http->addHeader('Connection', 'Close');

       if ($http->Get('/' . $api_dll . '?' . $request)) $body = $http->getBody();
 //mail('user@localhost.com','USPS rate quote response',$body,'From: <user@localhost.com>');
       if ($transit && is_array($transreq) && ($order->delivery['country']['id'] == STORE_COUNTRY)) {
         while (list($key, $value) = each($transreq)) {
           if ($http->Get('/' . $api_dll . '?' . $value)) $transresp[$key] = $http->getBody();
 //mail('user@localhost.com','USPS rate quote response',$transresp[$key],'From: <user@localhost.com>');
         }
       }

       $http->Disconnect();

     } else {
       return false;
     }


     $response = array();
     while (true) {
       if ($start = strpos($body, '<Package ID=')) {
         $body = substr($body, $start);
         $end = strpos($body, '</Package>');
         $response[] = substr($body, 0, $end+10);
         $body = substr($body, $end+9);
       } else {
         break;
       }
     }
           $rates = array();
     $rates_sorter = array();
     if ($order->delivery['country']['id'] == SHIPPING_ORIGIN_COUNTRY) {
       if (sizeof($response) == '1') {
         if (ereg('<Error>', $response[0])) {
           $number = ereg('<Number>(.*)</Number>', $response[0], $regs);
           $number = $regs[1];
           $description = ereg('<Description>(.*)</Description>', $response[0], $regs);
           $description = $regs[1];

           return array('error' => $number . ' - ' . $description);
         }
       }

       $n = sizeof($response);
       for ($i=0; $i<$n; $i++) {
         if (strpos($response[$i], '<Rate>')) {
           $service = ereg('<MailService>(.*)</MailService>', $response[$i], $regs);

           $service = $regs[1];
           $postage = ereg('<Rate>(.*)</Rate>', $response[$i], $regs);
           $postage = $regs[1];
                       $insurance = ereg('<Insurance>(.*)</Insurance>', $response[$i], $regs);
                       $insurance = $regs[1];

           switch ($service) {
             case 'Express Mail':
               $time = ereg('<MonFriCommitment>(.*)</MonFriCommitment>', $transresp[$service], $tregs);
               $time = $tregs[1];
               if ($time == '' || $time == 'No Data') {
                 $time = MODULE_SHIPPING_USPS_TEXT_ESTIMATED . ' 1 - 2 ' . MODULE_SHIPPING_USPS_TEXT_DAYS;
               } else {
                 $time = MODULE_SHIPPING_USPS_TEXT_TOMORROW . $time;
               }
                                                   $postage = $postage + $this->handling[0];
               break;
             case 'Express Mail Flat-Rate Envelope':
                     $time = ereg('<MonFriCommitment>(.*)</MonFriCommitment>', $transresp[$service], $tregs);
               $time = $tregs[1];
               if ($time == '' || $time == 'No Data') {
                 $time = MODULE_SHIPPING_USPS_TEXT_ESTIMATED . ' 1 - 2 ' . MODULE_SHIPPING_USPS_TEXT_DAYS;
               } else {
                 $time = MODULE_SHIPPING_USPS_TEXT_TOMORROW . $time;
               }
                                             $postage = $postage + $this->handling[0];
               break;
             case 'Priority Mail':
               $time = ereg('<Days>(.*)</Days>', $transresp[$service], $tregs);
               $time = $tregs[1];
               if ($time == '' || $time == 'No Data') {
                 $time = MODULE_SHIPPING_USPS_TEXT_ESTIMATED . ' 1 - 3 ' . MODULE_SHIPPING_USPS_TEXT_DAYS;
               } elseif ($time == '1') {
                 $time .= ' ' . MODULE_SHIPPING_USPS_TEXT_DAY;
               } else {
                 $time .= ' ' . MODULE_SHIPPING_USPS_TEXT_DAYS;
               }
                                             $postage = $postage + $this->handling[1];
               break;
                   case 'Priority Mail Flat-Rate Envelope':
                     $time = ereg('<Days>(.*)</Days>', $transresp[$service], $tregs);
               $time = $tregs[1];
               if ($time == '' || $time == 'No Data') {
                 $time = MODULE_SHIPPING_USPS_TEXT_ESTIMATED . ' 1 - 3 ' . MODULE_SHIPPING_USPS_TEXT_DAYS;
               } elseif ($time == '1') {
                 $time .= ' ' . MODULE_SHIPPING_USPS_TEXT_DAY;
               } else {
                 $time .= ' ' . MODULE_SHIPPING_USPS_TEXT_DAYS;
               }
                                             $postage = $postage + $this->handling[2];
               break;
                          case 'Priority Mail Flat-Rate Box':
                            $time = ereg('<Days>(.*)</Days>', $transresp[$service], $tregs);
               $time = $tregs[1];
               if ($time == '' || $time == 'No Data') {
                 $time = MODULE_SHIPPING_USPS_TEXT_ESTIMATED . ' 1 - 3 ' . MODULE_SHIPPING_USPS_TEXT_DAYS;
               } elseif ($time == '1') {
                 $time .= ' ' . MODULE_SHIPPING_USPS_TEXT_DAY;
               } else {
                 $time .= ' ' . MODULE_SHIPPING_USPS_TEXT_DAYS;
               }
                                                    $postage = $postage + $this->handling[3];
               break;
             case 'Parcel Post':
               $time = ereg('<Days>(.*)</Days>', $transresp[$service], $tregs);
               $time = $tregs[1];
               if ($time == '' || $time == 'No Data') {
                 $time = MODULE_SHIPPING_USPS_TEXT_ESTIMATED . ' 2 - 9 ' . MODULE_SHIPPING_USPS_TEXT_DAYS;
               } elseif ($time == '1') {
                 $time .= ' ' . MODULE_SHIPPING_USPS_TEXT_DAY;
               } else {
                 $time .= ' ' . MODULE_SHIPPING_USPS_TEXT_DAYS;
               }
                                             $postage = $postage + $this->handling[5];
               break;
             case 'First-Class Mail':
               $time = MODULE_SHIPPING_USPS_TEXT_ESTIMATED . ' 1 - 5 ' . MODULE_SHIPPING_USPS_TEXT_DAYS;
                                             $postage = $postage + $this->handling[4];
               break;
                               case 'Media Mail':
                                       $time = MODULE_SHIPPING_USPS_TEXT_ESTIMATED . ' 2 - 9 ' . MODULE_SHIPPING_USPS_TEXT_DAYS;
                                             $postage = $postage + $this->handling[7];
               break;
                               case 'Bound Printed Matter':
                                       $time = MODULE_SHIPPING_USPS_TEXT_ESTIMATED . ' 2 - 9 ' . MODULE_SHIPPING_USPS_TEXT_DAYS;
                                             $postage = $postage + $this->handling[6];
               break;
             default: 
               $time = '';
               break;
           }
                       $rates[] = array($service => $postage);
           $rates_sorter[] = $postage;
           if ($transit) {
             if ($time != '') $transittime[$service] = ' (' . $time . ') ';
           }
         }
       }
     } else {
       if (ereg('<Error>', $response[0])) {
         $number = ereg('<Number>(.*)</Number>', $response[0], $regs);
         $number = $regs[1];
         $description = ereg('<Description>(.*)</Description>', $response[0], $regs);
         $description = $regs[1];

         return array('error' => $number . ' - ' . $description);
       } else {
         $body = $response[0];
         $services = array();
         while (true) {
           if ($start = strpos($body, '<Service ID=')) {
             $body = substr($body, $start);
             $end = strpos($body, '</Service>');
             $services[] = substr($body, 0, $end+10);
             $body = substr($body, $end+9);
           } else {
             break;
           }
         }
         $allowed_types = array();
         //foreach( explode(", ", MODULE_SHIPPING_USPS_TYPES_INTL) as $value ) $allowed_types[$value] = $this->intl_types[$value];

         $allowed_types = explode(', ',MODULE_SHIPPING_USPS_TYPES_INTL);

         $size = sizeof($services);
         for ($i=0, $n=$size; $i<$n; $i++) {
           if (strpos($services[$i], '<Postage>')) {
             $service = ereg('<SvcDescription>(.*)</SvcDescription>', $services[$i], $regs);
                         $service = $regs[1];
             $postage = ereg('<Postage>(.*)</Postage>', $services[$i], $regs);
             $postage = $regs[1];

             $time = ereg('<SvcCommitments>(.*)</SvcCommitments>', $services[$i], $tregs);
             $time = $tregs[1];
             $time = preg_replace('/Weeks$/', MODULE_SHIPPING_USPS_TEXT_WEEKS, $time);
             $time = preg_replace('/Days$/', MODULE_SHIPPING_USPS_TEXT_DAYS, $time);
             $time = preg_replace('/Day$/', MODULE_SHIPPING_USPS_TEXT_DAY, $time);
                         $time = ' (' . $time . ') ';

             if( !in_array($service, $allowed_types) ) continue;
             if (isset($this->service) && ($service != $this->service) ) {
               continue;
             }

                 if (strpos($services[$i], '<Insurance>')) {
                         $iinsurance = ereg('<Insurance>(.*)</Insurance>', $services[$i], $regs);
       $iinsurance = $regs[1];
                         if (MODULE_SHIPPING_INTL_INSURANCE_OPTION == 'Force Insurance') {
                                 $postage = $postage + $iinsurance;
                                 if ($iinsurance > 0) {
                                         $time = ($time . ' ~~' . MODULE_SHIPPING_USPS_TEXT_INSURED . ' $' . $order->info['total'] . '~~');
                                 }
                         }
                 }
                 $postage = $postage + $handling_cost[$i];

                 $rates[] = array($service => $postage);
             $rates_sorter[] = $postage;


                 if ($time != '') $transittime[$service] = $time;
           }
         }
       }
     }
       //Sort Rates
       print_r($handling_cost);
       asort($rates_sorter);
       $sorted_rates = array();
       foreach (array_keys($rates_sorter) as $key){
               $sorted_rates[] = $rates[$key];
       }

       return ((sizeof($sorted_rates) > 0) ? $sorted_rates : false);
 }

   function country_list() {
     $list = array('AF' => 'Afghanistan',
                   'AL' => 'Albania',
                   'DZ' => 'Algeria',
                   'AD' => 'Andorra',
                   'AO' => 'Angola',
                   'AI' => 'Anguilla',
                   'AG' => 'Antigua and Barbuda',
                   'AR' => 'Argentina',
                   'AM' => 'Armenia',
                   'AW' => 'Aruba',
                   'AU' => 'Australia',
                   'AT' => 'Austria',
                   'AZ' => 'Azerbaijan',
                   'BS' => 'Bahamas',
                   'BH' => 'Bahrain',
                   'BD' => 'Bangladesh',
                   'BB' => 'Barbados',
                   'BY' => 'Belarus',
                   'BE' => 'Belgium',
                   'BZ' => 'Belize',
                   'BJ' => 'Benin',
                   'BM' => 'Bermuda',
                   'BT' => 'Bhutan',
                   'BO' => 'Bolivia',
                   'BA' => 'Bosnia-Herzegovina',
                   'BW' => 'Botswana',
                   'BR' => 'Brazil',
                   'VG' => 'British Virgin Islands',
                   'BN' => 'Brunei Darussalam',
                   'BG' => 'Bulgaria',
                   'BF' => 'Burkina Faso',
                   'MM' => 'Burma',
                   'BI' => 'Burundi',
                   'KH' => 'Cambodia',
                   'CM' => 'Cameroon',
                   'CA' => 'Canada',
                   'CV' => 'Cape Verde',
                   'KY' => 'Cayman Islands',
                   'CF' => 'Central African Republic',
                   'TD' => 'Chad',
                   'CL' => 'Chile',
                   'CN' => 'China',
                   'CX' => 'Christmas Island (Australia)',
                   'CC' => 'Cocos Island (Australia)',
                   'CO' => 'Colombia',
                   'KM' => 'Comoros',
                   'CG' => 'Congo (Brazzaville),Republic of the',
                   'ZR' => 'Congo, Democratic Republic of the',
                   'CK' => 'Cook Islands (New Zealand)',
                   'CR' => 'Costa Rica',
                   'CI' => 'Cote d\'Ivoire (Ivory Coast)',
                   'HR' => 'Croatia',
                   'CU' => 'Cuba',
                   'CY' => 'Cyprus',
                   'CZ' => 'Czech Republic',
                   'DK' => 'Denmark',
                   'DJ' => 'Djibouti',
                   'DM' => 'Dominica',
                   'DO' => 'Dominican Republic',
                   'TP' => 'East Timor (Indonesia)',
                   'EC' => 'Ecuador',
                   'EG' => 'Egypt',
                   'SV' => 'El Salvador',
                   'GQ' => 'Equatorial Guinea',
                   'ER' => 'Eritrea',
                   'EE' => 'Estonia',
                   'ET' => 'Ethiopia',
                   'FK' => 'Falkland Islands',
                   'FO' => 'Faroe Islands',
                   'FJ' => 'Fiji',
                   'FI' => 'Finland',
                   'FR' => 'France',
                   'GF' => 'French Guiana',
                   'PF' => 'French Polynesia',
                   'GA' => 'Gabon',
                   'GM' => 'Gambia',
                   'GE' => 'Georgia, Republic of',
                   'DE' => 'Germany',
                   'GH' => 'Ghana',
                   'GI' => 'Gibraltar',
                   'GB' => 'Great Britain and Northern Ireland',
                   'GR' => 'Greece',
                   'GL' => 'Greenland',
                   'GD' => 'Grenada',
                   'GP' => 'Guadeloupe',
                   'GT' => 'Guatemala',
                   'GN' => 'Guinea',
                   'GW' => 'Guinea-Bissau',
                   'GY' => 'Guyana',
                   'HT' => 'Haiti',
                   'HN' => 'Honduras',
                   'HK' => 'Hong Kong',
                   'HU' => 'Hungary',
                   'IS' => 'Iceland',
                   'IN' => 'India',
                   'ID' => 'Indonesia',
                   'IR' => 'Iran',
                   'IQ' => 'Iraq',
                   'IE' => 'Ireland',
                   'IL' => 'Israel',
                   'IT' => 'Italy',
                   'JM' => 'Jamaica',
                   'JP' => 'Japan',
                   'JO' => 'Jordan',
                   'KZ' => 'Kazakhstan',
                   'KE' => 'Kenya',
                   'KI' => 'Kiribati',
                   'KW' => 'Kuwait',
                   'KG' => 'Kyrgyzstan',
                   'LA' => 'Laos',
                   'LV' => 'Latvia',
                   'LB' => 'Lebanon',
                   'LS' => 'Lesotho',
                   'LR' => 'Liberia',
                   'LY' => 'Libya',
                   'LI' => 'Liechtenstein',
                   'LT' => 'Lithuania',
                   'LU' => 'Luxembourg',
                   'MO' => 'Macao',
                   'MK' => 'Macedonia, Republic of',
                   'MG' => 'Madagascar',
                   'MW' => 'Malawi',
                   'MY' => 'Malaysia',
                   'MV' => 'Maldives',
                   'ML' => 'Mali',
                   'MT' => 'Malta',
                   'MQ' => 'Martinique',
                   'MR' => 'Mauritania',
                   'MU' => 'Mauritius',
                   'YT' => 'Mayotte (France)',
                   'MX' => 'Mexico',
                   'MD' => 'Moldova',
                   'MC' => 'Monaco (France)',
                   'MN' => 'Mongolia',
                   'MS' => 'Montserrat',
                   'MA' => 'Morocco',
                   'MZ' => 'Mozambique',
                   'NA' => 'Namibia',
                   'NR' => 'Nauru',
                   'NP' => 'Nepal',
                   'NL' => 'Netherlands',
                   'AN' => 'Netherlands Antilles',
                   'NC' => 'New Caledonia',
                   'NZ' => 'New Zealand',
                   'NI' => 'Nicaragua',
                   'NE' => 'Niger',
                   'NG' => 'Nigeria',
                   'KP' => 'North Korea (Korea, Democratic People\'s Republic of)',
                   'NO' => 'Norway',
                   'OM' => 'Oman',
                   'PK' => 'Pakistan',
                   'PA' => 'Panama',
                   'PG' => 'Papua New Guinea',
                   'PY' => 'Paraguay',
                   'PE' => 'Peru',
                   'PH' => 'Philippines',
                   'PN' => 'Pitcairn Island',
                   'PL' => 'Poland',
                   'PT' => 'Portugal',
                   'QA' => 'Qatar',
                   'RE' => 'Reunion',
                   'RO' => 'Romania',
                   'RU' => 'Russia',
                   'RW' => 'Rwanda',
                   'SH' => 'Saint Helena',
                   'KN' => 'Saint Kitts (St. Christopher and Nevis)',
                   'LC' => 'Saint Lucia',
                   'PM' => 'Saint Pierre and Miquelon',
                   'VC' => 'Saint Vincent and the Grenadines',
                   'SM' => 'San Marino',
                   'ST' => 'Sao Tome and Principe',
                   'SA' => 'Saudi Arabia',
                   'SN' => 'Senegal',
                   'YU' => 'Serbia-Montenegro',
                   'SC' => 'Seychelles',
                   'SL' => 'Sierra Leone',
                   'SG' => 'Singapore',
                   'SK' => 'Slovak Republic',
                   'SI' => 'Slovenia',
                   'SB' => 'Solomon Islands',
                   'SO' => 'Somalia',
                   'ZA' => 'South Africa',
                   'GS' => 'South Georgia (Falkland Islands)',
                   'KR' => 'South Korea (Korea, Republic of)',
                   'ES' => 'Spain',
                   'LK' => 'Sri Lanka',
                   'SD' => 'Sudan',
                   'SR' => 'Suriname',
                   'SZ' => 'Swaziland',
                   'SE' => 'Sweden',
                   'CH' => 'Switzerland',
                   'SY' => 'Syrian Arab Republic',
                   'TW' => 'Taiwan',
                   'TJ' => 'Tajikistan',
                   'TZ' => 'Tanzania',
                   'TH' => 'Thailand',
                   'TG' => 'Togo',
                   'TK' => 'Tokelau (Union) Group (Western Samoa)',
                   'TO' => 'Tonga',
                   'TT' => 'Trinidad and Tobago',
                   'TN' => 'Tunisia',
                   'TR' => 'Turkey',
                   'TM' => 'Turkmenistan',
                   'TC' => 'Turks and Caicos Islands',
                   'TV' => 'Tuvalu',
                   'UG' => 'Uganda',
                   'UA' => 'Ukraine',
                   'AE' => 'United Arab Emirates',
                   'UY' => 'Uruguay',
                   'UZ' => 'Uzbekistan',
                   'VU' => 'Vanuatu',
                   'VA' => 'Vatican City',
                   'VE' => 'Venezuela',
                   'VN' => 'Vietnam',
                   'WF' => 'Wallis and Futuna Islands',
                   'WS' => 'Western Samoa',
                   'YE' => 'Yemen',
                   'ZM' => 'Zambia',
                   'ZW' => 'Zimbabwe');

     return $list;
   }

// Set up list of maximum allowed insurance values  

   function country_maxinsure() {
     $list = array('AF' => 0,
                   'AL' => 0,
                   'DZ' => 2185,
                   'AD' => 5000,
                   'AO' => 0,
                   'AI' => 415,
                   'AG' => 60,
                   'AR' => 5000,
                   'AM' => 1350,
                   'AW' => 830,
                   'AU' => 3370,
                   'AT' => 5000,
                   'AZ' => 5000,
                   'BS' => 2795,
                   'BH' => 0,
                   'BD' => 5000,
                   'BB' => 220,
                   'BY' => 1323,
                   'BE' => 5000,
                   'BZ' => 1600,
                   'BJ' => 170,
                   'BM' => 440,
                   'BT' => 440,
                   'BO' => 0,
                   'BA' => 5000,
                   'BW' => 145,
                   'BR' => 5000,
                   'VG' => 165,
                   'BN' => 4405,
                   'BG' => 1030,
                   'BF' => 530,
                   'MM' => 4045,
                   'BI' => 790,
                   'KH' => 0,
                   'CM' => 5000,
                   'CA' => 675,
                   'CV' => 0,
                   'KY' => 0,
                   'CF' => 4405,
                   'TD' => 440,
                   'CL' => 0,
                   'CN' => 1130,
                   'CX' => 3370,
                   'CC' => 3370,
                   'CO' => 0,
                   'KM' => 690,
                   'CG' => 1685,
                   'ZR' => 0,
                   'CK' => 980,
                   'CR' => 0,
                   'CI' => 5000,
                   'HR' => 5000,
                   'CU' => 0,
                   'CY' => 5000,
                   'CZ' => 5000,
                   'DK' => 5000,
                   'DJ' => 880,
                   'DM' => 0,
                   'DO' => 0,
                   'TP' => 0,
                   'EC' => 0,
                   'EG' => 1685,
                   'SV' => 0,
                   'GQ' => 0,
                   'ER' => 0,
                   'EE' => 2020,
                   'ET' => 1000,
                   'FK' => 510,
                   'FO' => 5000,
                   'FJ' => 600,
                   'FI' => 5000,
                   'FR' => 5000,
                   'GF' => 5000,
                   'PF' => 1015,
                   'GA' => 485,
                   'GM' => 2575,
                   'GE' => 1350,
                   'DE' => 5000,
                   'GH' => 5000,
                   'GI' => 5000,
                   'GB' => 857,
                   'GR' => 5000,
                   'GL' => 5000,
                   'GD' => 350,
                   'GP' => 5000,
                   'GT' => 0,
                   'GN' => 875,
                   'GW' => 21,
                   'GY' => 10,
                   'HT' => 0,
                   'HN' => 0,
                   'HK' => 5000,
                   'HU' => 5000,
                   'IS' => 5000,
                   'IN' => 2265,
                   'ID' => 0,
                   'IR' => 0,
                   'IQ' => 0,
                   'IE' => 5000,
                   'IL' => 0,
                   'IT' => 5000,
                   'JM' => 0,
                   'JP' => 5000,
                   'JO' => 0,
                   'KZ' => 5000,
                   'KE' => 815,
                   'KI' => 0,
                   'KW' => 1765,
                   'KG' => 1350,
                   'LA' => 0,
                   'LV' => 1350,
                   'LB' => 440,
                   'LS' => 440,
                   'LR' => 440,
                   'LY' => 0,
                   'LI' => 5000,
                   'LT' => 5000,
                   'LU' => 5000,
                   'MO' => 4262,
                   'MK' => 2200,
                   'MG' => 675,
                   'MW' => 50,
                   'MY' => 1320,
                   'MV' => 0,
                   'ML' => 950,
                   'MT' => 5000,
                   'MQ' => 5000,
                   'MR' => 635,
                   'MU' => 270,
                   'YT' => 5000,
                   'MX' => 0,
                   'MD' => 1350,
                   'MC' => 5000,
                   'MN' => 440,
                   'MS' => 2200,
                   'MA' => 5000,
                   'MZ' => 0,
                   'NA' => 4405,
                   'NR' => 220,
                   'NP' => 0,
                   'NL' => 5000,
                   'AN' => 830,
                   'NC' => 1615,
                   'NZ' => 980,
                   'NI' => 440,
                   'NE' => 810,
                   'NG' => 205,
                   'KP' => 0,
                       'SY' => 3080,
                   'TW' => 1350,
                   'TJ' => 1350,
                   'TZ' => 230,
                   'TH' => 1350,
                   'TG' => 2190,
                   'TK' => 295,
                   'TO' => 515,
                   'TT' => 930,
                   'TN' => 2200,
                   'TR' => 880,
                   'TM' => 675,
                   'TC' => 0,
                   'TV' => 4715,
                   'UG' => 0,
                   'UA' => 5000,
                   'AE' => 5000,
                   'UY' => 0,
                   'UZ' => 5000,
                   'VU' => 0,
                   'VA' => 5000,
                   'VE' => 0,
                   'VN' => 0,
                   'WF' => 1615,
                   'WS' => 295,
                   'YE' => 0,
                   'ZM' => 540,
                   'ZW' => 600,
                   'US' => 5000);

     return $list;
   }
 }
?>

 

And my /includes/languages/english/modules/shipping/usps.php is as follows:

 

<?php
/*
 $Id: usps.php,v 1.1.1.1 2005/12/03 21:36:11 max Exp $
 ++++ modified as USPS Methods 2.5 08/02/03 by Brad Waite and Fritz Clapp ++++

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2002 osCommerce

 Released under the GNU General Public License
*/

define('MODULE_SHI               'SY' => 3080,
                   'TW' => 1350,
                   'TJ' => 1350,
                   'TZ' => 230,
                   'TH' => 1350,
                   'TG' => 2190,
                   'TK' => 295,
                   'TO' => 515,
                   'TT' => 930,
                   'TN' => 2200,
                   'TR' => 880,
                   'TM' => 675,
                   'TC' => 0,
                   'TV' => 4715,
                   'UG' => 0,
                   'UA' => 5000,
                   'AE' => 5000,
                   'UY' => 0,
                   'UZ' => 5000,
                   'VU' => 0,
                   'VA' => 5000,
                   'VE' => 0,
                   'VN' => 0,
                   'WF' => 1615,
                   'WS' => 295,
                   'YE' => 0,
                   'ZM' => 540,
                   'ZW' => 600,
                   'US' => 5000);

     return $list;
   }
 }
?>

 

And my /includes/languages/english/modules/shipping/usps.php is as follows:

 

<?php
/*
 $Id: usps.php,v 1.1.1.1 2005/12/03 21:36:11 max Exp $
 ++++ modified as USPS Methods 2.5 08/02/03 by Brad Waite and Fritz Clapp ++++

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2002 osCommerce

 Released under the GNU General Public License
*/

define('MODULE_SHIPPING_USPS_TEXT_TITLE', 'United States Postal Service');
define('MODULE_SHIPPING_USPS_TEXT_DESCRIPTION', 'United States Postal Service<br><br>You will need to have registered an account with USPS at http://www.uspsprioritymail.com/et_regcert.html to use this module<br><br>USPS expects you to use pounds as weight measure for your products.');
define('MODULE_SHIPPING_USPS_TEXT_OPT_PP', 'Parcel Post');
define('MODULE_SHIPPING_USPS_TEXT_OPT_PM', 'Priority Mail');
define('MODULE_SHIPPING_USPS_TEXT_OPT_EX', 'Express Mail');
define('MODULE_SHIPPING_USPS_TEXT_POSTCODE_ERROR', '<span style="color: red;">If you prefer to use USPS as your shipping method, please enter your post code</span>');
define('MODULE_SHIPPING_USPS_TEXT_ERROR', 'An error occured with the USPS shipping calculations.<br>If you prefer to use USPS as your shipping method, please contact the store owner.');
define('MODULE_SHIPPING_USPS_TEXT_DAY', 'Day');
define('MODULE_SHIPPING_USPS_TEXT_DAYS', 'Days');
define('MODULE_SHIPPING_USPS_TEXT_WEEKS', 'Weeks');
define('MODULE_SHIPPING_USPS_TEXT_NOT_FOUND', 'An error occured with the USPS shipping calculations - no methods found!');
define('MODULE_SHIPPING_USPS_TEXT_ESTIMATED', 'Estimated');
define('MODULE_SHIPPING_USPS_TEXT_INSURED', 'Insured for');
define('MODULE_SHIPPING_USPS_TEXT_TOMORROW', 'Tomorrow by ');
?>

 

Thanks for taking a look at this.

 

Don

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×