Jump to content
Latest News: (loading..)
Sign in to follow this  
heartbroke

Is USPS shipping module down

Recommended Posts

How to fix this problem?

 

1. ADD THIS FUNCTION TO admin/includes/functions/general.php

// USPS Methods 3.0

// Alias function for Store configuration values in the Administration Tool

function tep_cfg_select_multioption($select_array, $key_value, $key = '')

 

{

for ($i=0; $i<sizeof($select_array); $i++) {

$name = (($key) ? 'configuration[' . $key . '][]' :

 

'configuration_value');

$string .= '<br><input type="checkbox" name="' . $name . '" value="'

 

. $select_array[$i] . '"';

$key_values = explode( ", ", $key_value);

if ( in_array($select_array[$i], $key_values) ) $string .= '

 

CHECKED';

$string .= '> ' . $select_array[$i];

}

$string .= '<input type="hidden" name="' . $name . '"

 

value="--none--">';

return $string;

}

 

2. Install the last version of this contribution

http://www.oscommerce.com/community/contributions,487

 

Thanks

 

That worked thank you so much!!

Share this post


Link to post
Share on other sites

Hi All,

 

I'm using osCommerce v2.2. I am also having this problem since yesterday and I came up with some solutions for my scenario.

 

 

 

In usps.php, this was my code BEFORE:

 

$this->types = array('FIRST CLASS' => 'First-Class Mail (1 - 3 days)',

'PRIORITY' => 'Priority Mail (1 - 3 days)',

'EXPRESS' => 'Express Mail (Overnight, most locations)',

'Express Mail International' => 'Express Mail International (3 - 5 days)',

'Priority Mail International' => 'Priority Mail International (6 - 10 days)');

 

 

 

This is my code NOW:

 

$this->types = array('FIRST CLASS' => 'First-Class Mail (1 - 3 days)',

'PRIORITY' => 'Priority Mail (1 - 3 days)',

'EXPRESS' => 'Express Mail (Overnight, most locations)',

'Express Mail&lt;sup&gt;&amp;reg;&lt;/sup&gt; International' => 'Express Mail International (3 - 5 days)',

'Priority Mail&lt;sup&gt;&amp;reg;&lt;/sup&gt; International' => 'Priority Mail International (6 - 10 days)');

 

 

 

With this, I am able to see my shipping methods correctly without the special symbols.

My next problem was that the shipping method selection in checkout_shipping.php didn't have a default selected value.

So I made this change in checkout_shipping.php

 

for ($j=0, $n2=sizeof($quotes[$i]['methods']); $j<$n2; $j++) {

 

$current = str_replace('&lt;sup&gt;&amp;reg;&lt;/sup&gt;','',$quotes[$i]['id']. '_' . $quotes[$i]['methods'][$j]['id']);

$default = str_replace('<sup>&reg;</sup>','',$shipping['id']);

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

$checked = (( $current == $default ) ? true : false);

 

if ( ($checked == true) || ($n == 1 && $n2 == 1) ) {

 

 

 

But now my problem is that for International shipping methods, the selected shipping method isn't reflected correctly in the "order_confirmation.php" page. I always see "Priority Mail International" even if I have selected "Express Mail International".

 

I tried grapesmuggler's solution but I could not proceed to "order_confirmation.php". I think this is because the id of the shipping method was changed when we replaced the special symbols using str_replace().

 

 

p.s. I haven't used any usps method updates yet because everything was working fine before the holidays.

 

 

Anyone has better solutions? Please help! Thanks! :)

Share this post


Link to post
Share on other sites

@ezoscommerce -

Your USPS Methods 5.0.0 blew up on me:

 

Fatal error: Call to undefined function: htmlspecialchars_decode() in x:\xxxxx\xxxxx\xxxxx\oscommerce2\catalog\includes\modules\shipping\usps.php on line 400

Edited by TomB01

Share this post


Link to post
Share on other sites

@ezoscommerce

 

I had the admin code already installed from a while ago. I backed up everything, added the contribution, and the International shipping didn't work. I had no selections in the admin module and instead my customers were allowed all choices.

 

I went directly to database to try and fix, but didn't work.

 

I've tried to roll back, but that also doesn't work because my database has been changed. Now all I get after saving changes on the USPS module in the admin area on both Domestic and International is "array" and now I cannot take any orders.

 

Any help appreciated and clearly needed on this!


Jennifer

Share this post


Link to post
Share on other sites

Disregard this for the moment, testing has revealed a problem when I go to confirm the order, the wrong shipping option is shown and billed for. Eek!

 

 

My domestic shipping was working, but not the international. I fumbled through it, and by applying advice provided by a couple different contributors, I was able to get my system working again. Thanks to those who have been offering advice.

 

I have been using some old code, so here is the entire file. I customized my system when I originally installed it, but don't recall if there were any modifications to this file, other than choosing available shipping options.

 

The two areas in which I changed the code are in red.

 

 

<?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 (1-2 days)',

'FIRST CLASS' => 'First-Class Mail (3-4 days)',

'PRIORITY' => 'Priority Mail (2-3 days)',

'PARCEL' => 'Parcel Post (6 days)');

 

$this->intl_types = array('Express Mail&lt;sup&gt;&amp;reg;&lt;/sup&gt; International',

'Priority Mail&lt;sup&gt;&amp;reg;&lt;/sup&gt; International',

'First-Class Mail&lt;sup&gt;&amp;reg;&lt;/sup&gt; International Package**');

 

$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]);

 

$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);

 

$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;

}

 

if(!in_array($service, $this->intl_types)) {

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',

0 'YU' => 'Serbia-Montenegro',

'SC' => 'Seychelles',

'SL' => 'Sierra Leone',

'SG' => 'Singapore',

'SK' => 'Slovak Republic',

'SI' => 'Slovenia',

'SB' => 'Solomon Islands',

'SO' => 'Somalia',

'ZA' => 'South Africa',

'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;

}

}

?>

Edited by bradf30

Share this post


Link to post
Share on other sites

Here is My quick fix for USPS domestic rates and international issues i tested both and both are now working

 

 

Find

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

 

 

Find

$size = sizeof($uspsQuote);
         for ($i=0; $i<$size; $i++) {
           list($type, $cost) = each($uspsQuote[$i]);
$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);

 

Find

$service = ereg('<SvcDescription>(.*)</SvcDescription>', $services[$i], $regs);
	  $service = $regs[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);

Share this post


Link to post
Share on other sites

OK - at least I was able to roll mine back. So, I'm left where all this started: no International shipping.

 

I think perhaps USPS Methods 5.0.0 needs some work. ;)

Share this post


Link to post
Share on other sites

Here is My quick fix for USPS domestic rates and international issues i tested both and both are now working

 

 

Find

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

 

 

Find

$size = sizeof($uspsQuote);
         for ($i=0; $i<$size; $i++) {
           list($type, $cost) = each($uspsQuote[$i]);
$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);

 

Find

$service = ereg('<SvcDescription>(.*)</SvcDescription>', $services[$i], $regs);
	  $service = $regs[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);

OK, this was tough to figure out - what you meant for "find" and what was actually changed/added. I went through it and think I got it all. International shipping now partially works - I can't get First Class International, though.

Share this post


Link to post
Share on other sites

try this

 

$this->intl_types = array('GLOBAL EXPRESS' => 'Global Express Guaranteed', 
                                                               'GLOBAL EXPRESS NON-DOC RECT' => 'Global Express Guaranteed Non-Document Rectangular', 
                                                               'GLOBAL EXPRESS NON-DOC NON-RECT' => 'Global Express Guaranteed Non-Document Non-Rectangular', 
                                                               'EXPRESS MAIL INT' => 'Express Mail International', 
                                                               'EXPRESS MAIL INT FLAT RATE ENV' => 'Express Mail International Flat-Rate Envelope', 
                                                               'PRIORITY MAIL INT' => 'Priority Mail International', 
                                                               'PRIORITY MAIL INT FLAT RATE ENV' => 'Priority Mail International Flat-Rate Envelope', 
                                                               'PRIORITY MAIL INT FLAT RATE BOX' => 'Priority Mail International ' . $this->PriorityFlatRateBoxType, 
                                                               'FIRST-CLASS MAIL INT' => 'First Class Mail International package** ' . $this->FirstClassIntType',
                                                               'First Class Mail Int Lrg Env' => 'First-Class Mail International Large Envelope**', 
                                                               'First Class Mail Int Package' => 'First-Class Mail International Package**',
                                                               'First Class Mail Int Letter' => 'First-Class Mail International Letter**');

 

 

 

 

 

 

 

OK, this was tough to figure out - what you meant for "find" and what was actually changed/added. I went through it and think I got it all. International shipping now partially works - I can't get First Class International, though.

Share this post


Link to post
Share on other sites

@Maxtors

 

This worked mostly for me. My international shipping still won't calculate at all, but at least I have domestic back again.

 

I'll check back tomorrow.

 

Thanks,

Black Ops Toys

 

Here is My quick fix for USPS domestic rates and international issues i tested both and both are now working

 

 

Find

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

 

 

Find

$size = sizeof($uspsQuote);
         for ($i=0; $i<$size; $i++) {
           list($type, $cost) = each($uspsQuote[$i]);
$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);

 

Find

$service = ereg('<SvcDescription>(.*)</SvcDescription>', $services[$i], $regs);
	  $service = $regs[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);


Jennifer

Share this post


Link to post
Share on other sites

Here is an update: I could only get this to work with 1 international shipping options available, as on the order confirmation page it would always default to the first international shipping option listed in the code. I'm only allowing international customers to use International Priority Mail at the moment. Domestic appears to work correctly through to the order confirmation page. I tried Maxtors suggestions, but they didn't work for me. I may not have cut and pasted correctly.

 

Disregard this for the moment, testing has revealed a problem when I go to confirm the order, the wrong shipping option is shown and billed for. Eek!

 

 

My domestic shipping was working, but not the international. I fumbled through it, and by applying advice provided by a couple different contributors, I was able to get my system working again. Thanks to those who have been offering advice.

 

I have been using some old code, so here is the entire file. I customized my system when I originally installed it, but don't recall if there were any modifications to this file, other than choosing available shipping options.

 

The two areas in which I changed the code are in red.

 

 

<?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 (1-2 days)',

'FIRST CLASS' => 'First-Class Mail (3-4 days)',

'PRIORITY' => 'Priority Mail (2-3 days)',

'PARCEL' => 'Parcel Post (6 days)');

 

$this->intl_types = array('Express Mail&lt;sup&gt;&amp;reg;&lt;/sup&gt; International',

'Priority Mail&lt;sup&gt;&amp;reg;&lt;/sup&gt; International',

'First-Class Mail&lt;sup&gt;&amp;reg;&lt;/sup&gt; International Package**');

 

$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]);

 

$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);

 

$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;

}

 

if(!in_array($service, $this->intl_types)) {

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',

%20 'SG' => 'Singapore',

'SK' => 'Slovak Republic',

'SI' => 'Slovenia',

'SB' => 'Solomon Islands',

'SO' => 'Somalia',

'ZA' => 'South Africa',

'YU' => 'Serbia-Montenegro',

'SC' => 'Seychelles',

'SL' => 'Sierra Leone',

520 'SG' => 'Singapore',

'SK' => 'Slovak Republic',

'SI' => 'Slovenia',

'SB' => 'Solomon Islands',

'SO' => 'Somalia',

'ZA' => 'South Africa',

'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;

}

}

?>

Edited by bradf30

Share this post


Link to post
Share on other sites

Here is my code at present. It only allows International customers the option of International Priority Mail. Domestic works for Parcel Post, 1st Class, Priority, and Express Mail. I don't guarantee it works. Changed code is in red:

 

<?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 (1-2 days)',

'FIRST CLASS' => 'First-Class Mail (3-4 days)',

'PRIORITY' => 'Priority Mail (2-3 days)',

'PARCEL' => 'Parcel Post (6 days)');

 

$this->intl_types = array('Priority Mail&lt;sup&gt;&amp;reg;&lt;/sup&gt; 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]);

 

$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);

 

$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;

}

 

if(!in_array($service, $this->intl_types)) {

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;

}

}

?>

Share this post


Link to post
Share on other sites

I tried the

 

USPS Methods addon download from FEB 26, 2010

 

and incorporated this (found earlier in this thread):

 

Find 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);

 

 

and it seems to work. You have to manually comment out in the usps file the methods you don't want to offer, but once you do that it seems to function properly, well enough to accept domestic and international orders for now....until a better solution comes along that is fully functional.

Share this post


Link to post
Share on other sites

Hello again,

 

I was able to solve my problems.

1. Special symbols in USPS shipping methods

2. Incorrect shipping method passed to order_confirmation.php

3. Renaming the shipping methods to include the delivery time

 

 

This is what I did:

1. Downloaded USPS Methods for API v3 (osC 2.2) (dated 19 Feb 2010) from http://addons.oscommerce.com/info/487

2. Removed United States Postal Service from Admin > Modules > Shipping

3. Reinstalled United States Postal Service and defined my usps username/password

 

4. In usps.php

 

After the line:

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

 

Add these lines (Thanks to grapesmuggler for this):

$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);

 

 

5. In checkout shipping.php

 

Replace the line:

<td class="main" width="75%"><?php echo $quotes[$i]['methods'][$j]['title']; ?></td>

 

with:

<td class="main" width="75%"><?php

if(($quotes[$i]['methods'][$j]['title'])=='Express Mail') {

echo 'Express Mail (Overnight, most locations)';

}

else if(($quotes[$i]['methods'][$j]['title'])=='Priority Mail') {

echo 'Priority Mail (1 - 3 days)';

}

else if(($quotes[$i]['methods'][$j]['title'])=='Express Mail International') {

echo 'Express Mail International (3 - 5 days)';

}

else if(($quotes[$i]['methods'][$j]['title'])=='Priority Mail International') {

echo 'Priority Mail International (6 - 10 days)';

}

?></td>

 

 

That's it.. Thanks guys! I hope this helps.. :D

Share this post


Link to post
Share on other sites

Hello again,

 

I was able to solve my problems.

1. Special symbols in USPS shipping methods

2. Incorrect shipping method passed to order_confirmation.php

3. Renaming the shipping methods to include the delivery time

 

 

This is what I did:

1. Downloaded USPS Methods for API v3 (osC 2.2) (dated 19 Feb 2010) from http://addons.oscommerce.com/info/487

2. Removed United States Postal Service from Admin > Modules > Shipping

3. Reinstalled United States Postal Service and defined my usps username/password

 

4. In usps.php

 

After the line:

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

 

Add these lines (Thanks to grapesmuggler for this):

$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);

 

 

5. In checkout shipping.php

 

Replace the line:

<td class="main" width="75%"><?php echo $quotes[$i]['methods'][$j]['title']; ?></td>

 

with:

<td class="main" width="75%"><?php

if(($quotes[$i]['methods'][$j]['title'])=='Express Mail') {

echo 'Express Mail (Overnight, most locations)';

}

else if(($quotes[$i]['methods'][$j]['title'])=='Priority Mail') {

echo 'Priority Mail (1 - 3 days)';

}

else if(($quotes[$i]['methods'][$j]['title'])=='Express Mail International') {

echo 'Express Mail International (3 - 5 days)';

}

else if(($quotes[$i]['methods'][$j]['title'])=='Priority Mail International') {

echo 'Priority Mail International (6 - 10 days)';

}

?></td>

 

 

That's it.. Thanks guys! I hope this helps.. :D

 

I found that the file from Feb 19th is missing First Class mail.

The one from Feb 26th says it has First Class mail, but First Class mail is not working for me.

 

Thanks.

Share this post


Link to post
Share on other sites

That worked thank you so much!!

Solution: http://forums.oscommerce.com/topic/369224-is-usps-shipping-module-down/page__view__findpost__p__1556089

 

That worked for me too. :D

 

However I did have to edit /admin/includes/functions/general.php more because of previous USPS code insertions.

Edited by Seren2

Problem solving is a lifestyle, not an isolated activity.

Share this post


Link to post
Share on other sites

It worked for me too, thanks but I'm noticing that there is no more first class international option? are they not offering that anymore?

 

Thanks, -J

 

Solution: http://forums.oscommerce.com/topic/369224-is-usps-shipping-module-down/page__view__findpost__p__1556089

 

That worked for me too. :D

 

However I did have to edit /admin/includes/functions/general.php more because of previous USPS code insertions.

Share this post


Link to post
Share on other sites

It worked for me too, thanks but I'm noticing that there is no more first class international option? are they not offering that anymore?

 

Thanks, -J

If you go to your cart admin for the USPS module you will see these options:

 

  • First Class Mail Int Lrg Env
  • First Class Mail Int Package
  • First Class Mail Int Letter

Edited by Seren2

Problem solving is a lifestyle, not an isolated activity.

Share this post


Link to post
Share on other sites

ok so some links were provided for the solution, but when you go to them all you see is peices here and there. Is there an actual solution? If so can we post it here?

Share this post


Link to post
Share on other sites

ok so some links were provided for the solution, but when you go to them all you see is peices here and there. Is there an actual solution? If so can we post it here?

The new USPS Methods 5.0.1 and fix file seems to fix it for some people. It didn't for me, but maybe it will work for you. There are some changes that apparently must be made with the general.php file, too - that's in the txt file instructions.

 

Even though it didn't work for me correctly, seems like it's closer than anything else I've tried so far (I think I've tried all of them!). Make sure you back everything up so that you can roll it back if it ends up being worse!!

Share this post


Link to post
Share on other sites

The new USPS Methods 5.0.1 and fix file seems to fix it for some people. It didn't for me, but maybe it will work for you. There are some changes that apparently must be made with the general.php file, too - that's in the txt file instructions.

 

Even though it didn't work for me correctly, seems like it's closer than anything else I've tried so far (I think I've tried all of them!). Make sure you back everything up so that you can roll it back if it ends up being worse!!

 

Hey thank you, I did install 5.0 and everything looks good.

 

What are you having trouble with?

Share this post


Link to post
Share on other sites

Hey thank you, I did install 5.0 and everything looks good.

 

What are you having trouble with?

Still can't get First Class on International Shipping, and the new Methods blows up my Domestic shipping. Here's a post that explains it in detail in the module support thread: http://forums.oscommerce.com/topic/146950-contribution-usps-methods/page__view__findpost__p__1556409

Share this post


Link to post
Share on other sites

Ok... a few things.

 

1) I have the same problem (duh... obviouslY).

2) I also have the Contribution "Estimated Shipping 1.6" installed... which gives the same problem.

3) The problem USUALLY does NOT show up during USA>USA orders... but ALWAYS shows up for USA>INTERNATIONAL orders.

4) I am now getting "An error occured with the USPS shipping calculations. If you prefer to use USPS as your shipping method, please contact the store owner." which tells me that they they know it is a real problem and are working on it.

 

Pete


I find the fun in everything.

Share this post


Link to post
Share on other sites

Ok... a few things.

 

1) I have the same problem (duh... obviouslY).

2) I also have the Contribution "Estimated Shipping 1.6" installed... which gives the same problem.

3) The problem USUALLY does NOT show up during USA>USA orders... but ALWAYS shows up for USA>INTERNATIONAL orders.

4) I am now getting "An error occured with the USPS shipping calculations. If you prefer to use USPS as your shipping method, please contact the store owner." which tells me that they they know it is a real problem and are working on it.

 

Pete

Unfortunately, this:

An error occured with the USPS shipping calculations. If you prefer to use USPS as your shipping method, please contact the store owner.

is simply the coded error message in the usps.php file of the USPS contribs module. The US Post Office has nothing to do with that message.

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
Sign in to follow this  

×