Jump to content
Sign in to follow this  
RPerez007

UPS and Extended Routes and Address Validation

Recommended Posts

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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

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  

×