Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

USPS to Canada- Intermittent problem


JPLewis

Recommended Posts

I am running 2.2 MS2 with the Estimated Shipping Cost add-on, version 1.7a... I only use USPS and I only ship to the USA and Canada. Sometimes when a Canadian customer tries to order they get an error that says, "An error occured with the USPS shipping calculations. If you prefer to use USPS as your shipping method, please contact the store owner." It behaves as though they put in a bogus ZIP code...

 

The curious thing is that it only happens sometimes... I thought it might be a space in their ZIP code but I edited a customer account and that did not fix it.

 

I emailed another OSCommerce user who told me that there is an update to the USPS shipping module... he seemed to think there was some change made several months ago but a search is not turning up any discussions of this on the forums. Looking through the shipping contributions isn't helping either... any suggestions?

 

Thanx in advance....

Link to comment
Share on other sites

Thanks for the response, Gaurav... the problem is intermittent... some Canadian orders go thru fine, others get the error I mentioned above. I had another Canadian customer email me after I posted this... they get stuck at "Delivery Information" page and can not go forward, as though they entered a bogus ZIP code. I reproduced this error message by dropping the last digit of my ZIP code in my own account... it's like the USPS shipping module does not recognize all Canadian ZIP codes...

 

Is there an "update" of the USPS module...? Has something changed? I have made no significant changes to the code in over a year, but now I have this problem...

Link to comment
Share on other sites

If USPS - doesn't recognize a valid CODE, it would not process it.

Nothing wrong in your side / OSC, but you have to ensure that postal code is recognized by USPS.

 

Go to includes\modules\shipping\usps.php

function _getQuote() is used for fetching information from USPS.

 

Add echo for $body ( I prefer to define it as belows to avoid customers to see it, while I am testing on a live site.. :) )

echo "<font color=white>".$body.</font> ;

 

This would then shift your header down and if you select text - show what was the message sent by USPS - to narrow down / identify the problem.

 

 

Cheers

GS

Best Regards,
Gaurav

Link to comment
Share on other sites

Here is my usps.php file... you are going a little over my head, Guarav... I understand what you want me to do, I just don't know where to stick that echo...

 

<?php
/*
 $Id: usps.php,v 1.47 2003/04/08 23:23:42 dgw_ Exp $

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

 Copyright (c) 2003 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(//'GXG Document' => 'Global Express Guaranteed Document Service',
							//'GXG Non-Document' => 'Global Express Guaranteed Non-Document Service',
							//'Express' => 'Global Express Mail (EMS)',
							'Priority Lg' => 'Global Priority Mail - Flat-rate Envelope (large)',
							//'Priority Sm' => 'Global Priority Mail - Flat-rate Envelope (small)',
							//'Priority Var' => 'Global Priority Mail - Variable Weight Envelope (single)',
							//'Airmail Letter' => 'Airmail Letter Post',
							'Airmail Parcel' => 'Airmail Parcel Post',
							//'Surface Letter' => 'Economy (Surface) Letter Post',
							'Surface Post' => 'Economy (Surface) Parcel Post');

  $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, 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, 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_SERVER', '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);
  }

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

  $body = '';

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

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

			elseif(!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;
}
 }
?>

Link to comment
Share on other sites

In function _getQuote() Look for following section and add echo as I suggested.

 

if ($http->Get('/' . $api_dll . '?' . $request)) $body = $http->getBody();
echo "<font color=white>".$body."</font>";
	$http->Disconnect();
  } else {
	return false;
  }

 

Then run a dummy checkout with canada codes that give problems.

If you get error, you would notice your complete site / header (logo) would shift down because in white font, the message from USPS would be pushed on top.

 

Simply select all text to read what message came from USPS. (esp last line)

 

You can move forward from there to narrow down the problem.

 

HTH,

 

Cheers

GS

Best Regards,
Gaurav

Link to comment
Share on other sites

Holy Smokes! This is what I got! WTF...?

 

 

 

An issue of a publication in which more than 5 percent of its total advertising space is primarily directed to a Canadian market and which indicates: (a) specifically where goods or services may be obtained in Canada, or (B) specific items or conditions relating to the sale or provision of goods or services in Canada. All alcoholic beverages including wines, etc. An issue of a publication that contains an advertisement primarily directed to a Canadian market is a prohibited import if that advertisement does not appear in identical form in all editions of the issue distributed in the country of origin. Articles so marked as to create the false impression that they were made in Canada, Great Britain or any other British country. Butane gas lighters and refill cartridges. Commercial tags of metal. Firearms, including prohibited and restricted weapons, may not be mailed to Canadian addressees from outside Canada. Oleomargarine and other butter substitutes, including altered or renovated butter. Shipments bearing caution labels indicating the contents are flammable. Perishable infectious biological substances. Perishable noninfectious biological substances. Plumage and skins of wild birds. Prison-made goods being sold or intended for sale by a person or firm. Radioactive materials. Reprints of Canadian or British works copyrighted in Canada. Reproductions of Canadian postage stamps unless printed in publications in black and white only and with a defacing line drawn across each reproduction. Smoke-making devices for motor vehicles and boats. Used or secondhand hives or bee supplies.Coins; banknotes; currency notes; securities payable to bearer; traveler's checks; gold, silver, platinum, manufactured or not; jewelry; and other valuable articles may be sent only in registered letter-post items. Exceptions: Coins sent to or from collectors or dealers may be mailed in ordinary (uninsured) parcel post packages. Jewelry and precious stones may be sent via GPL Air Courier (Premium) service to Canada subject to indemnity limits indicated in section 626.31. Drugs and medicines must comply with Canadian law. Eggs for hatching must be packed in new, clean containers and accompanied by a certificate issued by a veterinarian of the U.S. Department of Agriculture, or one issued by a State veterinarian and endorsed by a veterinarian of that Bureau, stating that to the best of his or her knowledge the eggs come from a flock that is free from Newcastle disease, fowl pest, or fowl typhoid. See 135.3 for method of packing. Meat and meat food products must be accompanied by an export certificate issued by the U.S. Department of Agriculture and labeled in accordance with Canadian regulations. Exception to these requirements are: (1) bona fide sample shipments weighing less than 10 kg; (2) meat products addressed to a government department or agency; (3) meat products intended for personal consumption when they enter Canada in the possession of the importer. Precious stones, set or not set; all items used as dress ornaments and coming under the term "jewelry" including articles of gold or other precious metal for personal use such as cigarette holders, cases, powder cases, card cases, opera glasses, fountain pens, watches, etc., are permitted in insured parcel post packages provided the articles have value not over $5 U.S. A parcel post package containing a number of such articles valued at $5 or less may be insured for the total value of the contents up to a maximum of $200. Senders are advised to communicate with prospective addressees to assure themselves before mailing that such articles will be admitted. Veterinary biological products including serums and vaccines must be accompanied by a permit issued by the Veterinary Director General, Ministry of Agriculture of Canada.1. Banknotes valued at $100 or more must be put up in a compact package and securely tied with strong twine before wrapping. The wrapper must be linen or other strong, woven material, linen lined paper, or two thicknesses of strong kraft paper. After wrapping, the package must be again securely tied or stitched and sealed at the points of closing. 2. The name of the Canadian province in which the office of destination is located must appear as part of the address. 3. The following must not be accepted for insurance: Bees, postage stamps (canceled and uncanceled) and albums in which they are mounted, and parcel post packages addressed to CFPOs. 4. Canadian Forces Mail (CFPO) is processed through Canadian military post offices and must be addressed in the following manner: NUMBER, RANK, NAME UNIT CFPO (NUMBER) BELLEVILLE, ONT CANADA K0K 3R0 Maximum weight limits for mail addressed to members of the Canadian Forces based outside of Canada (CFPO) is: 22 pounds. Parcel post packages for CFPO addresses may not be insured. Direct sacks of printed matter (M Bags) are not permitted for CFPO addresses. 5. Advertising matter specially prepared to promote the sale of goods or services by Canadian persons or firms is charged with customs duty in Canada when the total weight of articles mailed at one time exceeds one pound. Duty is charged on each individually addressed article. To avoid detention of such mail by Canadian customs, senders may arrange to pay the duty, which can be done by means of Canadian customs duty stamps affixed to the back of each piece of mail. Senders may inquire as to rates of duty and may purchase the duty stamps from the Department of National Revenue, Customs and Excise, Ottawa, Ont., Canada. 6. A letter fully prepaid and bearing the same address as that of the parcel post package may be tied or otherwise securely attached to the outside of the parcel. Stamps to cover postage on the parcel post package must be affixed to the wrapper of the parcel. Stamps to pay postage on the letter must be affixed to the envelope thereof. 7. Certain types of merchandise must be marked to show country of origin in the manner prescribed by the Canadian customs regulations. 8. Goods valued under 20 Canadian dollars are duty and excise tax exempt. Goods over 20 Canadian dollars will be subject to the applicable duties and excise taxes. Gift shipments received by mail that are valued under 60 Canadian dollars are duty and excise tax exempt. 9. For all casual and commercial items valued under 1,200 Canadian dollars, Canada Post will collect the assessed duties and excise taxes and a handling fee of 5 Canadian dollars from the addressee. For EMS items, the handling fee is 8 Canadian dollars. All commercial mail items over 1,200 Canadian dollars will be held by Canada Customs and Excise until proper invoice and accounting documentation is provided by the addressee. 10. The Canada Customs Invoice can be obtained from stationery, office supply, or printing companies. If mailers are unable to obtain the Canada Customs Invoice locally, they should write to the following office that will apply specific names and addresses from which the invoice may be obtained: REVENUE CANADA, CUSTOMS AND EXCISE CONNAUGHT BUILDING OTTAWA ON K1A 0L5 CANADA Attn: Release and Documentation Systems Data Control Programmes. 11. Information on Canadian customs regulations may be obtained from the Office of International Marketing/223, Bureau of International Commerce, Department of Commerce, Washington, DC 20230, or any field office of that Department. 12. (a) Information on Canadian post code directories can be obtained from: NATIONAL PHILATELIC CENTER CANADA POST CORPORATION STATION 1 ANTIGONISH NS B2G 2R8 Telephone: 1-800-565-4362 Fax: 1-902-863-6796 (B) To obtain Canadian post codes for specific addresses, call the General Information line at 1-416-0979-8822 or access the Canada Post Corporation web site on the Internet at http://www.canadapost.ca 13. Registered mail to Canada has an indemnity limit of $1,000, with the exception of cash that has an indemnity limit of $200.Letter-post: PS Form 2976 or 2976-A (see 123.61) Parcel Post: PS Form 2976-A inside 2976-E (envelope) (Customs Form Information -- http://ircalc.usps.gov/custforms.htm)Country Code: CA Reciprocal Service Name: There is no reciprocal service. Required Customs Form/Endorsement 1. Business papers and commercial documents. PS Form 2976, Customs - CN 22 (Old C 1) and Sender's Declaration (green label). 2. Merchandise samples and gift shipments (non-commercial parcels). PS Form 2976-A, Customs Declaration and Dispatch Note CP 72, inside a PS Form 2976-E, Customs Declaration Envelope CP 91. 3. Merchandise (commercial shipments) and all articles subject to customs duty. PS Form 2976-A, Customs Declaration and Dispatch Note CP 72, inside a PS Form 2976-E, Customs Declaration Envelope CP 91. Notes: 1. Gift shipments (non-commercial parcels) require a sales receipt, invoice or other documentation to support the declared value. 2. Coins; banknotes; currency notes (paper money); securities of any kind payable to bearer; traveler's checks; platinum, gold, and silver (manufactured or not); precious stones; jewelry; and other valuable articles are prohibited in EMS shipments to Canada. 3. Express Mail shipments may have a street address or a post office box address. A local telephone number for the addressee MUST be provided for shipments addressed to a post office box address. A local telephone number for the addressee should be provided if possible for shipments to a street address. Areas Served: AllPlease reference Express Mail for Areas Served.20PackageCANADA44.51 - 3 DaysGlobal Express GuaranteedMax. length 46", width 35", height 46" and max. length plus girth 108"7020PackageCANADA44.51 - 3 DaysGlobal Express Guaranteed Non-Document RectangularMax. length 46", width 35", height 46" and max. length plus girth 108"7020PackageCANADA44.51 - 3 DaysGlobal Express Guaranteed Non-Document Non-RectangularMax. length 46", width 35", height 46" and max. length plus girth 108"7020PackageCANADA255 DaysExpress Mail International (EMS)Max.length 42", max. length plus girth 79"6620PackageCANADA225 DaysExpress Mail International (EMS) Flat Rate Envelope9 1/2" X 12 1/2"6620PackageCANADA17.36 - 10 DaysPriority Mail InternationalMaximum length and girth combined 108"6620PackageCANADA96 - 10 DaysPriority Mail International Flat Rate EnvelopeUSPS-supplied Priority Mail flat-rate envelope 9 1/2" x 12 1/2." Maximum weight 4 pounds.420PackageCANADA236 - 10 DaysPriority Mail International Flat Rate BoxUSPS-supplied Priority Mail flat-rate box. Maximum weight 20 pounds.2020PackageCANADA8.26VariesFirst-Class Mail InternationalMax. length 24", Max. length, height, depth combined 36"64

Link to comment
Share on other sites

Yeah .. all that gets transferred while you blink after clicking ..

As far as I can see - this time you didn't get error on your page? Correct me if I'm wrong?

 

you need to get postal code that is giving error - and this information would tell you why it failed.

 

Cheers

GS

 

 

To turn of debugging ..just remove echo from your code.

Best Regards,
Gaurav

Link to comment
Share on other sites

Yeah .. all that gets transferred while you blink after clicking ..

As far as I can see - this time you didn't get error on your page? Correct me if I'm wrong?

 

No.... I created a new shipping address for my account and put in the ZIP code of the Canadian customer that had a problem today. I added your code to my usps.php file and tried to check out with the Canadian address. This is the error message that appeared in white at the top of my page...

 

I still got the "An error occured..." error message...

Link to comment
Share on other sites

OK, got it,

Replace $body by $description and move this code just above line shown below

echo "<font color=white>".$description."</font>"; 
 return ((sizeof($rates) > 0) ? $rates : false);

 

and let me know what do you get now.

 

Thnks

GS

Best Regards,
Gaurav

Link to comment
Share on other sites

In case you have not figured it out all that text you got in debug mode is showing a small part of Canadian customs/importation law. I recognize some of it. just an idea here but perhaps some of your customers are using k6k 1a1 instead of K6K 1A1 Canadian postal codes use capital letters, and or perhaps some of them are putting in KOC instead of K0C etc.

Not sure if capital letters will make the difference but its worth to look and see what your customers are using perhaps there is a pattern of failures u can locate even tho it looks sporadic

Chris.

Link to comment
Share on other sites

Thanx for jumping in, Chris... I understand that I am looking at Canadian postal regulations; the question is, why is the post office sending them to my cart...? I checked and capitalization is not the issue either... I also looked to see if it was just one province, like say, Alberta, but I am not seeing any pattern there either...

 

I can't believe I am the only person to ever have this issue... any other ideas, folks...?

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...