You are here

function commerce_avatax_options in Drupal Commerce Connector for AvaTax 7.4

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

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

Parameters

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

Return value

array An options array of calculated AvaTax rates labelled using the display title of the AvaTax services.

1 call to commerce_avatax_options()
commerce_avatax_line_item_add_form in ./commerce_avatax.module
Returns form for adding an AvaTax line item through line item manager widget.
1 string reference to 'commerce_avatax_options'
commerce_avatax_ui_admin_settings in includes/commerce_avatax_ui.admin.inc
Admin settings menu callback.

File

./commerce_avatax.module, line 374
Calculate Sales Tax using AvaTax 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;
}