function commerce_avatax_line_item_add_form_submit in Drupal Commerce Connector for AvaTax 7.3
Same name and namespace in other branches
- 7.4 commerce_avatax.module \commerce_avatax_line_item_add_form_submit()
Adds the selected tax saas information to a new tax saas line item.
Parameters
$line_item: The newly created line item object.
$element: The array representing the widget form element.
$form_state: The present state of the form upon the latest submission.
$form: The actual form array.
Return value
NULL if all is well or an error message if something goes wrong.
File
- ./
commerce_avatax.module, line 382 - Calculate Sales Tax using AvaTax Calc service from Avalara, Inc.
Code
function commerce_avatax_line_item_add_form_submit($line_item, $element, &$form_state, $form) {
$order = $form_state['commerce_order'];
// 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);
}