For Drupal 6.x version
For Ups address validation dynamically at time of checkout.Dynamically checking whether its Residential or Commercial .
I have not developed any module to add address validation.
Just a simple way I have did it.
Added function in my custom module.
function check_shipping_address($address)
{
require_once('Address_validation.php');
$av = new Address_validation();
$av->setReturnType('Array'); // Array or json (Default)
// $address['address1'],$address['city'],$address['state'],$address['zipcode'],$address['country'] is required
// $address['country'] = 'US' Only
$av->setAddress($address);
$data = $av->getResponse();
/*echo "
data=="; print_r($data); echo "
"; */
return $data[0][description];
}
In ubercart/shipping/uc_ups/uc_ups.module file
i have added the code in function
function uc_ups_shipping_quote($packages, $origin, $destination, $ups_service) { .. }
After line 327 .
$shipto_city = $destination->city;
$shipto_address = $destination->street1;
For getting the address and city of ShipTo.
Then format a array .
Add it after line 346.
$addresscheck = array("address1" =>$shipto_address ,
"city" => $shipto_city,
"state" => $shipto_zone,
"zipcode" => $shipto_zip,
"country" => $shipto_country);
Now in schema I have added and check whether its commercial or Residential address.
on Line 445.
if(check_shipping_address($addresscheck)=='Residential') // Call a function and pass the address
{
$schema .= "
";
}
Thanks. if you need my help let me know.
Comments
Address validation
Forgot to show code of Address_validation.php
Put this file in your custom module where you have enter the function of addresscheck
".ACCESS_LICENSE_NUMBER."
".USER_ID."
".USER_PASSWORD."
<?xml version='1.0' ?>
1.0001
XAV
3
3
";
if($this->_consignee) $xml .= " UPS Capital";
$xml .= "".$this->_address1."";
if($this->_address2) $xml .= "#2L";
$xml .= "
".$this->_city."
".$this->_state."
".$this->_zipcode."
".$this->_country."
";
return $xml;
}
}//class
?>