You are here

function commerce_avatax_line_item_populate in Drupal Commerce Connector for AvaTax 7.4

Same name and namespace in other branches
  1. 7.3 commerce_avatax.module \commerce_avatax_line_item_populate()

Populates a sales tax line item with the specified values.

Parameters

array $sales_tax: A sales tax array to be added to the value of the line item's unit price.

2 calls to commerce_avatax_line_item_populate()
commerce_avatax_line_item_add_form_submit in ./commerce_avatax.module
Adds the selected AvaTax information to a new AvaTax line item.
commerce_avatax_line_item_new in ./commerce_avatax.module
Creates a new AvaTax line item populated with the sales tax values.

File

./commerce_avatax.module, line 255
Calculate Sales Tax using AvaTax service from Avalara, Inc.

Code

function commerce_avatax_line_item_populate($line_item, $sales_tax = array()) {
  $avatax_service = commerce_avatax_service_load();

  // Use the label to store the display title of the avatax service.
  $line_item->line_item_label = 'AvaTax';
  $line_item->quantity = 1;
  $line_item->data['avatax'] = $avatax_service;
  $line_item_wrapper = entity_metadata_wrapper('commerce_line_item', $line_item);

  // Set the unit price.
  $line_item_wrapper = entity_metadata_wrapper('commerce_line_item', $line_item);
  $line_item_wrapper->commerce_unit_price = $sales_tax;
}