Jump to content



Latest News: (loading..)

- - - - -

UPS and Extended Routes and Address Validation


  • Please log in to reply
3 replies to this topic

#1   RPerez007

RPerez007
  • Members
  • 1 posts
  • Real Name:Richard Perez

Posted 25 May 2011 - 01:08 PM

This is not a question but a finding that I hope helps someone. In dealing with the UPS module 1.3.9 I noticed I was not getting cost for Residential addresses which cost more nor was I getting pricing for routes UPS calls "Extended" routes. (Never knew that even existed).

Looking over the UPS XML guidelines I came across this line of text. <AddressLine1></AddressLine1>

I included this XML code into my XML text that is sent to UPS from the module and BAM! I got correct shipping costs for residential addresses and extended routes.

Here's where I inserted the code so if someone wants to "update" the UPS module, that would be great. (I'm still very new to osC)

Look for:
<Address>
  <City></City>
  <StateProvinceCode></StateProvinceCode>
etc...

Change to:
<Address>
  <AddressLine1></AddressLine1>
  <City></City>
  <StateProvinceCode></StateProvinceCode>
etc...

And you will have to update your code to include the street address be fed into the XML file.

When you send the data to UPS, it should give the shipping cost with consideration on whether UPS considers the address to be commercial or residential, (Mind you, UPS determines whether it's commercial or residential) and whether it's an extended route for UPS.

I hope this is helpful to someone.

#2   Roaddoctor

Roaddoctor
  • Members
  • 905 posts
  • Real Name:David Jennings
  • Gender:Not Telling
  • Location:Texas

Posted 01 August 2011 - 05:57 PM

Using UPS XML 1.3.9.1
So if we add this to /includes/modules/shipping/upsxml.php around line 539

		"			   <AddressLine1>". $this->_upsDestAddressLine1 ."</AddressLine1>\n".  // testing auto RES quote

so it looks like:

		"	   <ShipTo>\n".
		"		   <Address>\n".
		"			   <AddressLine1>". $this->_upsDestAddressLine1 ."</AddressLine1>\n".  // testing auto RES quote
		"			   <City>". $this->_upsDestCity ."</City>\n".
		"			   <StateProvinceCode>". $this->_upsDestStateProv ."</StateProvinceCode>\n".
		"			   <CountryCode>". $this->_upsDestCountryCode ."</CountryCode>\n".
		"			   <PostalCode>". $this->_upsDestPostalCode ."</PostalCode>\n".
		($this->quote_type == "Residential" ? "<ResidentialAddressIndicator/>\n" : "") .
		"		   </Address>\n".
		"	   </ShipTo>\n";


Then what else (and where) would I need to add to make upsDestAddressLine1 work?
-Dave

#3   Roaddoctor

Roaddoctor
  • Members
  • 905 posts
  • Real Name:David Jennings
  • Gender:Not Telling
  • Location:Texas

Posted 01 August 2011 - 10:21 PM

then above the first change, around line 446-447, I changed this:

these two lines
	function _upsDest($_upsDestAddressLine1, $city, $stateprov, $country, $postal) {  //test auto RES quote
		$this->_upsDestAddressLine1 = $_upsDestAddressLine1; // test auto RES quote

to look like

	function _upsDest($_upsDestAddressLine1, $city, $stateprov, $country, $postal) {  //test auto RES quote
		$this->_upsDestAddressLine1 = $_upsDestAddressLine1; // test auto RES quote
		$this->_upsDestCity = $city;
		$this->_upsDestStateProv = $stateprov;
		$this->_upsDestCountryCode = $country;
		$postal = str_replace(' ', '', $postal);
		if ($country == 'US') {
			$this->_upsDestPostalCode = substr($postal, 0, 5);
			$territories = array('AS','FM','GU','MH','MP','PR','PW','VI');
			if (in_array($this->_upsDestStateProv,$territories)) {
			  $this->_upsDestCountryCode = $stateprov;
			  }
		} else if ($country == 'BR') {
			$this->_upsDestPostalCode = substr($postal, 0, 5);
		} else {
			$this->_upsDestPostalCode = $postal;
		}
	}

Am I on the right track here? if so what else is required?  thanks
-Dave

#4   Roaddoctor

Roaddoctor
  • Members
  • 905 posts
  • Real Name:David Jennings
  • Gender:Not Telling
  • Location:Texas

Posted 02 August 2011 - 02:05 AM

So this works!
With the Quote Type setting to "Commercial" in the admin, UPS XML is now showing correct Residential rates to residential addresses...

Using UPS XML 1.3.9.1 on a RC2a shop

Backup! then open /includes/modules/shipping/upsxml.php

Around line 245, replace
		$this->_upsDest($order->delivery['city'], $state, $order->delivery['country']['iso_code_2'], $order->delivery['postcode']);
with
		$this->_upsDest($order->delivery['street_address'], $order->delivery['city'], $state, $order->delivery['country']['iso_code_2'], $order->delivery['postcode']);


Around line 446, replace
	function _upsDest($city, $stateprov, $country, $postal) {
with
	function _upsDest($street_address, $city, $stateprov, $country, $postal) {
		$this->_upsDestAddressLine1 = $street_address;


Around line 541, replace
		"		   <Address>\n".
with
		"		   <Address>\n".
		"			   <AddressLine1>". $this->_upsDestAddressLine1 ."</AddressLine1>\n".

Thats it. Hopefully this will help others
-Dave