function commerce_avatax_check_address in Drupal Commerce Connector for AvaTax 7.4
Same name and namespace in other branches
- 7.5 commerce_avatax.module \commerce_avatax_check_address()
Is AvaTax service to be used for this transaction.
3 calls to commerce_avatax_check_address()
- commerce_avatax_calculate_sales_tax in ./
commerce_avatax.module - Calculate sales tax using regular web site checkout.
- commerce_avatax_manual_calculate_sales_tax in ./
commerce_avatax.module - Calculate sales tax for manual order entry.
- _commerce_avatax_update in ./
commerce_avatax.rules.inc - Send Commit/Cancel operation to AvaTax.
File
- ./
commerce_avatax.module, line 1180 - Calculate Sales Tax using AvaTax service from Avalara, Inc.
Code
function commerce_avatax_check_address($order, $product_version) {
$order_wrapper = entity_metadata_wrapper('commerce_order', $order);
$tax_address_profile = variable_get('commerce_avatax_tax_address', '');
if ($tax_address_profile == 'Billing') {
if (isset($order_wrapper->commerce_customer_billing->commerce_customer_address)) {
$billing_address = $order_wrapper->commerce_customer_billing->commerce_customer_address
->value();
$state = $billing_address['administrative_area'];
$country = $billing_address['country'];
}
}
elseif ($tax_address_profile == 'Shipping') {
if (isset($order_wrapper->commerce_customer_shipping->commerce_customer_address)) {
$shipping_address = $order_wrapper->commerce_customer_shipping->commerce_customer_address
->value();
$state = $shipping_address['administrative_area'];
$country = $shipping_address['country'];
}
}
// Exit if not a valid AvaTax state.
$avatax_states = variable_get('commerce_avatax_select_states', array());
if (!empty($avatax_states) && !in_array($state, $avatax_states)) {
return FALSE;
}
return TRUE;
}