function commerce_avatax_validate_address in Drupal Commerce Connector for AvaTax 7.4
Same name and namespace in other branches
- 7.5 includes/commerce_avatax.address.inc \commerce_avatax_validate_address()
Validate the shipping address entered on checkout form.
1 call to commerce_avatax_validate_address()
- commerce_avatax_form_alter in ./
commerce_avatax.module - Implements hook_form_alter().
3 string references to 'commerce_avatax_validate_address'
- commerce_avatax_form_alter in ./
commerce_avatax.module - Implements hook_form_alter().
- commerce_avatax_ui_admin_settings in includes/
commerce_avatax_ui.admin.inc - Admin settings menu callback.
- commerce_avatax_ui_validate_address_validation_settings in includes/
commerce_avatax_ui.admin.inc - Disable address validation when address is taken from Billing profile.
File
- ./
commerce_avatax.module, line 998 - Calculate Sales Tax using AvaTax service from Avalara, Inc.
Code
function commerce_avatax_validate_address($address) {
$product_version = variable_get('commerce_avatax_product_version', COMMERCE_AVATAX_BASIC_VERSION);
$use_mode = variable_get('commerce_avatax_use_mode', COMMERCE_AVATAX_DEVELOPMENT_MODE);
$account_no = variable_get('commerce_avatax_' . $product_version . '_' . $use_mode . '_account');
$license_key = variable_get('commerce_avatax_' . $product_version . '_' . $use_mode . '_license');
if (!$product_version || !$use_mode || !$account_no || !$license_key) {
return FALSE;
}
$parameters = array();
if ($address['line1']) {
$parameters['Line1'] = $address['line1'];
}
if ($address['line2']) {
$parameters['Line2'] = $address['line2'];
}
if ($address['city']) {
$parameters['City'] = $address['city'];
}
if ($address['state']) {
$parameters['Region'] = $address['state'];
}
if ($address['postal_code']) {
$parameters['PostalCode'] = $address['postal_code'];
}
$result = commerce_avatax_get('address/validate', $parameters);
if (!$result['body']) {
watchdog('commerce_avatax', 'Could not connect to AvaTax for address validation.');
return NULL;
}
elseif ($result['body']['ResultCode'] != 'Success') {
return array();
}
return $result['body']['Address'];
}