You are here

function commerce_avatax_manual_calculate_sales_tax in Drupal Commerce Connector for AvaTax 7.3

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

Calculate sales tax for manual order entry.

1 call to commerce_avatax_manual_calculate_sales_tax()
commerce_avatax_line_item_add_form in ./commerce_avatax.module
Returns a form with the elements required to add an AvaTax line item through the line item manager widget.

File

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

Code

function commerce_avatax_manual_calculate_sales_tax($order) {
  $sales_tax = commerce_avatax_retrieve_sales_tax($order);

  // If we have a sales tax amount.
  if ($sales_tax) {

    // Create a new AvaTax line item.
    $line_item = commerce_avatax_line_item_create($sales_tax, $order->order_id);

    // Add the line item data as a property of the order.
    $order->avatax['avatax'] = $line_item;
  }
}