You are here

function commerce_tax_rate_rules_apply in Commerce Core 7

Rules action: loads and applies a tax rate to the given line item.

1 string reference to 'commerce_tax_rate_rules_apply'
commerce_tax_rules_action_info in modules/tax/commerce_tax.rules.inc
Implements hook_rules_action_info().

File

modules/tax/commerce_tax.rules.inc, line 152
Rules integration for line items.

Code

function commerce_tax_rate_rules_apply($line_item, $name) {
  if ($tax_rate = commerce_tax_rate_load($name)) {
    $tax_price = commerce_tax_rate_apply($tax_rate, $line_item);

    // If tax was applied, return the price array as a new variable for use in
    // subsequent actions.
    if ($tax_price) {
      return array(
        'applied_tax' => $tax_price,
      );
    }
  }
}