You are here

function commerce_tax_rules_action_info in Commerce Core 7

Implements hook_rules_action_info().

File

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

Code

function commerce_tax_rules_action_info() {
  $actions = array();
  $actions['commerce_tax_remove_taxes'] = array(
    'label' => t('Remove taxes applied to a line item'),
    'parameter' => array(
      'commerce_line_item' => array(
        'type' => 'commerce_line_item',
        'label' => t('Line item'),
        'wrapped' => TRUE,
        'save' => TRUE,
        'restriction' => 'selector',
      ),
      'increase_base_price' => array(
        'type' => 'boolean',
        'label' => t('Increase the base price amount by the amount of display inclusive taxes removed.'),
        'description' => t('If left unchecked, a price of £2.95 including £0.49 VAT will be reduced to £2.46. If checked it will be set to £2.95 with no tax included.'),
        'default value' => FALSE,
        'restriction' => 'input',
      ),
      'tax_rates' => array(
        'type' => 'list<text>',
        'label' => t('Limit removal to only a certain set of tax rates'),
        'description' => t('If no tax rates are selected, all tax rates will be removed from the line item. Use ctrl + click (or command + click) to deselect a tax rate.'),
        'options list' => 'commerce_tax_rate_titles',
        'optional' => TRUE,
        'restriction' => 'input',
      ),
    ),
    'group' => t('Commerce Tax'),
  );
  if (count(commerce_tax_rates()) > 0) {
    $actions['commerce_tax_rate_apply'] = array(
      'label' => t('Apply a tax rate to a line item'),
      'parameter' => array(
        'commerce_line_item' => array(
          'type' => 'commerce_line_item',
          'label' => t('Line item'),
        ),
        'tax_rate_name' => array(
          'type' => 'text',
          'label' => t('Tax rate'),
          'options list' => 'commerce_tax_rate_titles',
        ),
      ),
      'provides' => array(
        'applied_tax' => array(
          'type' => 'commerce_price',
          'label' => t('Applied tax'),
        ),
      ),
      'group' => t('Commerce Tax'),
      'callbacks' => array(
        'execute' => 'commerce_tax_rate_rules_apply',
      ),
    );
  }
  if (count(commerce_tax_types()) > 0) {
    $actions['commerce_tax_calculate_by_type'] = array(
      'label' => t('Calculate taxes for a line item'),
      'parameter' => array(
        'commerce_line_item' => array(
          'type' => 'commerce_line_item',
          'label' => t('Line item'),
        ),
        'tax_type_name' => array(
          'type' => 'text',
          'label' => t('Tax type'),
          'options list' => 'commerce_tax_type_titles',
        ),
      ),
      'group' => t('Commerce Tax'),
    );
  }
  return $actions;
}