function commerce_avatax_line_item_add_form in Drupal Commerce Connector for AvaTax 7.3
Same name and namespace in other branches
- 7.4 commerce_avatax.module \commerce_avatax_line_item_add_form()
Returns a form with the elements required to add an AvaTax line item through the line item manager widget.
File
- ./
commerce_avatax.module, line 338 - Calculate Sales Tax using AvaTax Calc service from Avalara, Inc.
Code
function commerce_avatax_line_item_add_form($form, &$form_state) {
// Calculate the sales tax amount for this order.
$order = $form_state['commerce_order'];
commerce_avatax_manual_calculate_sales_tax($order);
// Store the available rates in the form.
$form = array();
$form['#attached']['css'][] = drupal_get_path('module', 'commerce_avatax') . '/theme/commerce_avatax.admin.css';
$form['avatax_rate'] = array(
'#type' => 'value',
'#value' => $order->avatax,
);
// Create an options array for the sales tax amount
$options = commerce_avatax_options($order);
$form['avatax'] = array(
'#type' => 'radios',
'#title' => t('AvaTax Calc'),
'#options' => $options,
'#default_value' => key($options),
);
return $form;
}