function commerce_avatax_line_item_new in Drupal Commerce Connector for AvaTax 7.3
Same name and namespace in other branches
- 7.5 commerce_avatax.module \commerce_avatax_line_item_new()
- 7.4 commerce_avatax.module \commerce_avatax_line_item_new()
Creates a new AvaTax line item populated with the sales tax values.
Parameters
$sales_tax: A price array used to initialize the value of the line item's unit price.
$order_id: The ID of the order the line item belongs to.
$data: An array value to initialize the line item's data array with.
$type: The name of the line item type being created; defaults to 'avatax'.
Return value
The avatax line item initialized to the given unit price.
1 call to commerce_avatax_line_item_new()
- commerce_avatax_line_item_create in ./
commerce_avatax.module - Creates a sales tax line item
File
- ./
commerce_avatax.module, line 260 - Calculate Sales Tax using AvaTax Calc service from Avalara, Inc.
Code
function commerce_avatax_line_item_new($sales_tax, $order_id = 0, $data = array(), $type = 'avatax') {
// Ensure a default product line item type.
if (empty($type)) {
$type = 'avatax';
}
// Create the new line item.
$line_item = entity_create('commerce_line_item', array(
'type' => $type,
'order_id' => $order_id,
'quantity' => 1,
'data' => $data,
));
// Populate line item with the sales tax unit price data.
commerce_avatax_line_item_populate($line_item, $sales_tax);
return $line_item;
}