Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

UPS and Extended Routes and Address Validation


RPerez007

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.

Link to comment
Share on other sites

  • 2 months later...

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

Link to comment
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

Link to comment
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

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...