You are here

function commerce_avatax_options in Drupal Commerce Connector for AvaTax 7.3

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

Turns the sales tax amount into a form element options array.

Parameters

$order: An order object with an avatax property defined as an array of sales tax values.

Return value

An options array of calculated tax saas rates labeled using the display title of the tax saas services.

1 call to commerce_avatax_options()
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 408
Calculate Sales Tax using AvaTax Calc service from Avalara, Inc.

Code

function commerce_avatax_options($order) {
  $options = array();
  $line_item = $order->avatax['avatax'];
  $line_item_wrapper = entity_metadata_wrapper('commerce_line_item', $line_item);
  $options['avatax'] = t('!avatax: !price', array(
    '!avatax' => 'Sales tax',
    '!price' => commerce_currency_format($line_item_wrapper->commerce_unit_price->amount
      ->value(), $line_item_wrapper->commerce_unit_price->currency_code
      ->value()),
  ));
  return $options;
}