Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Update for the USPS international shipping rates


Guest

Recommended Posts

Posted

Hi,

 

The USPS International Rates API engine was recently updated. For international orders, no matter what shipping method you select from the USPS shipping options, when it goes to the checkout confirmation, it displays the price for "Global Express Guaranteed Document Service".

 

For those with the same problem here is how to fix.

- Backup files

- Edit the file 'catalog/includes/modules/shipping/usps.php'

 

Replace this:

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

With this:

	  $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 (Single)',
							'Airmail Letter' => 'Airmail Letter Post',
							'Airmail Parcel' => 'Airmail Parcel Post',
							'Surface Letter' => 'Economy (Surface) Letter Post',
							'Surface Post' => 'Economy (Surface) Parcel Post');

Hope this will help :)

  • 2 months later...
Posted

For international orders, I'm still having trouble. When I select "Global Priority Mail - Flat-rate Envelope (Large)" or "Global Priority Mail - Flat-rate Envelope (Small)" or "Global Priority Mail - Variable Weight Envelope (Single)" from the USPS shipping options, when it goes to the checkout confirmation, it still displays the price for "Global Express Guaranteed Document Service". Does anyone know how to fix this?

Posted

I dont see a diference between the two codes,

 

Jorge

 

Hi,

 

The USPS International Rates API engine was recently updated. For international orders, no matter what shipping method you select from the USPS shipping options, when it goes to the checkout confirmation, it displays the price for "Global Express Guaranteed Document Service".

 

For those with the same problem here is how to fix.

- Backup files

- Edit the file 'catalog/includes/modules/shipping/usps.php'

 

Replace this:

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

With this:

		   $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 (Single)',
							'Airmail Letter' => 'Airmail Letter Post',
							'Airmail Parcel' => 'Airmail Parcel Post',
							'Surface Letter' => 'Economy (Surface) Letter Post',
							'Surface Post' => 'Economy (Surface) Parcel Post');

Hope this will help :)

  • 1 month later...
Posted

If you are wanting to filter the results (services) you get from the USPS International Rate Calculator, here's how to do it:

 

 

In /includes/modules/shipping/usps.php, add the following code after the $this->intl_types array (the original, not the one posted above):

	$this->intl_services = array(
				'Global Express Guaranteed Document Service',
				'Global Express Guaranteed Non-Document Service',
				'Global Express Mail (EMS)',
				'Global Priority Mail - Flat-rate Envelope (Large)',
				'Global Priority Mail - Flat-rate Envelope (Small)',
				'Global Priority Mail - Variable Weight Envelope (Single)',
				'Airmail Letter-post',
				'Airmail Parcel Post',
				'Economy (Surface) Letter-post',
				'Economy (Surface) Parcel Post'
				);

Comment out any services you don't want to use (put // in front of the line).

 

Find this line:

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

and then find the else statement for that if block that looks like this:

	} else {
	  $services = $root->get_elements_by_tagname("Service");
	  foreach ($services as $service) {
		   $servicedetails=$this->_dom2array($service); 
		   $SvcDescription = $servicedetails['SvcDescription'] . ' ('. $servicedetails['SvcCommitments'] . ')';
		   $Postage=$servicedetails['Postage'];
		   if (isset($this->service) && ($SvcDescription != $this->service) ) continue;
		   $rates[$SvcDescription] = array($SvcDescription => $Postage); // trick to remove duplicates
	  }
 }

 

Replace the else block code with

	 } else {
	  $services = $root->get_elements_by_tagname("Service");
	  foreach ($services as $service) {
		   $servicedetails=$this->_dom2array($service); 
		   if (in_array($servicedetails['SvcDescription'],$this->intl_services)) {
				$SvcDescription = $servicedetails['SvcDescription'] . ' ('. $servicedetails['SvcCommitments'] . ')';
				$Postage=$servicedetails['Postage'];
				if (isset($this->service) && ($SvcDescription != $this->service) ) continue;
				$rates[$SvcDescription] = array($SvcDescription => $Postage); // trick to remove duplicates
		   }
	  }   
 }

 

 

Feel free to correct as necessary, but that's my homemade solution. ;)

 

Ryan

  • 2 months later...
Posted
...add the following code after the $this->intl_types array (the original, not the one posted above):

	$this->intl_services = array(
				'Global Express Guaranteed Document Service',
				'Global Express Guaranteed Non-Document Service',
				'Global Express Mail (EMS)',
				'Global Priority Mail - Flat-rate Envelope (Large)',
				'Global Priority Mail - Flat-rate Envelope (Small)',
				'Global Priority Mail - Variable Weight Envelope (Single)',
				'Airmail Letter-post',
				'Airmail Parcel Post',
				'Economy (Surface) Letter-post',
				'Economy (Surface) Parcel Post'
				);

Comment out any services you don't want to use (put // in front of the line).

 

I'm a little unclear on the instruction above. I see the options above already in the file I have...

When you say "add the following code after the... do you mean duplicate the entry (I assume that's what you mean since it looks like at the end of the instructions you include another } to close out a new layer to the loop... is that right? Is it not enough to // out the ones in the first list that you don't want to offer?

 

Thanks Ryan!

Posted

If the $this->intl_services array is already in your code, don't bother it (as long as it has the same services as the ones I posted). Basically, anything that is in that array will be output as an option. So, if you comment out a line, that one won't be part of the array.

 

No problem!!

 

Ryan

 

I'm a little unclear on the instruction above. I see the options above already in the file I have...

When you say "add the following code after the... do you mean duplicate the entry (I assume that's what you mean since it looks like at the end of the instructions you include another } to close out a new layer to the loop... is that right? Is it not enough to // out the ones in the first list that you don't want to offer?

 

Thanks Ryan!

Posted
If the $this->intl_services array is already in your code, don't bother it (as long as it has the same services as the ones I posted). Basically, anything that is in that array will be output as an option. So, if you comment out a line, that one won't be part of the array.

 

No problem!!

 

Ryan

 

Uh oh... now I can't find the following section in the code at all:

} else {

$services = $root->get_elements_by_tagname("Service");

foreach ($services as $service) {

$servicedetails=$this->_dom2array($service);

$SvcDescription = $servicedetails['SvcDescription'] . ' ('. $servicedetails['SvcCommitments'] . ')';

$Postage=$servicedetails['Postage'];

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

$rates[$SvcDescription] = array($SvcDescription => $Postage); // trick to remove duplicates

}

}

 

Any ideas? I even went as far as deleting all the options but three... they are still all showing up when I test an international order. Could it have anything to do with the version of OS Commerce I'm running? My usps.php file is identified as usps.php,v 1.47 2003/04/08 23:23:42

Archived

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

×
×
  • Create New...