You are here

function commerce_avatax_line_item_populate in Drupal Commerce Connector for AvaTax 7.3

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

Populates a sales tax line item with the specified values.

Parameters

$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 tax saas information to a new tax saas 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 287
Calculate Sales Tax using AvaTax Calc service from Avalara, Inc.

Code

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

  // Use the label to store the display title of the avatax service.
  $line_item->line_item_label = 'AvaTax Calc';
  $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;
}