You are here

function commerce_vat_rules_action_info in Commerce VAT 7

Implements hook_rules_action_info().

File

./commerce_vat.rules.inc, line 13
Rules integration for line items.

Code

function commerce_vat_rules_action_info() {
  $actions = array();
  if (count(commerce_vat_rates()) > 0) {
    $actions['commerce_vat_rate_apply'] = array(
      'label' => t('Apply a vat rate to a line item'),
      'parameter' => array(
        'commerce_line_item' => array(
          'type' => 'commerce_line_item',
          'label' => t('Line item'),
        ),
        'vat_rate_name' => array(
          'type' => 'text',
          'label' => t('vat rate'),
          'options list' => 'commerce_vat_rate_titles',
        ),
      ),
      'provides' => array(
        'applied_vat' => array(
          'type' => 'commerce_price',
          'label' => t('Applied vat'),
        ),
      ),
      'group' => t('Commerce VAT'),
      'callbacks' => array(
        'execute' => 'commerce_vat_rate_rules_apply',
      ),
    );
    $actions['commerce_vat_order_rate'] = array(
      'label' => t('Get the highest VAT rate currently applied to an order'),
      'parameter' => array(
        'commerce_order' => array(
          'type' => 'commerce_order',
          'label' => t('Order'),
        ),
      ),
      'provides' => array(
        'order_vat_rate' => array(
          'type' => 'text',
          'label' => t('Order VAT Rate'),
        ),
      ),
      'group' => t('Commerce VAT'),
      'callbacks' => array(
        'execute' => 'commerce_vat_rules_order_rate',
      ),
    );
  }
  $actions['commerce_vat_calculate'] = array(
    'label' => t('Calculate VAT for a line item'),
    'parameter' => array(
      'commerce_line_item' => array(
        'type' => 'commerce_line_item',
        'label' => t('Line item'),
      ),
      'country' => array(
        'type' => 'text',
        'label' => t('ISO 2 Country Code'),
      ),
    ),
    'group' => t('Commerce VAT'),
    'callbacks' => array(
      'execute' => 'commerce_vat_rules_calculate',
    ),
  );
  $actions['commerce_vat_place_of_supply'] = array(
    'label' => t('Calculate Place of Supply for a line item'),
    'parameter' => array(
      'commerce_line_item' => array(
        'type' => 'commerce_line_item',
        'label' => t('Line item'),
      ),
    ),
    'group' => t('Commerce VAT'),
    'callbacks' => array(
      'execute' => 'commerce_vat_rules_place_of_supply',
    ),
  );
  return $actions;
}