function commerce_avatax_line_item_add_form_submit in Drupal Commerce Connector for AvaTax 7.4
Same name and namespace in other branches
- 7.3 commerce_avatax.module \commerce_avatax_line_item_add_form_submit()
Adds the selected AvaTax information to a new AvaTax line item.
Parameters
object $line_item: The newly created line item object.
array $element: The array representing the widget form element.
File
- ./
commerce_avatax.module, line 351 - Calculate Sales Tax using AvaTax service from Avalara, Inc.
Code
function commerce_avatax_line_item_add_form_submit($line_item, $element = array()) {
// Ensure a quantity of 1.
$line_item->quantity = 1;
// Use the values for avatax.
$line_item_wrapper = entity_metadata_wrapper('commerce_line_item', $element['actions']['avatax_rate']['#value']['avatax']);
$sales_tax = $line_item_wrapper->commerce_unit_price
->value();
// Populate the line item with the appropriate data.
commerce_avatax_line_item_populate($line_item, $sales_tax);
}