You are here

function commerce_stock_rules_action_info in Commerce Stock 7

Same name and namespace in other branches
  1. 7.2 commerce_stock.rules.inc \commerce_stock_rules_action_info()

Implements hook_rules_action_info().

Provides an action to adjust stock level of a certain product by a certain quantity.

File

./commerce_stock.rules.inc, line 14
Rules integration for Commerce Stock.

Code

function commerce_stock_rules_action_info() {
  $actions = array();

  /*
    $actions['commerce_stock_adjust'] = array(
      'label' => t('Adjust the product stock level by a set amount'),
      'group' => t('Commerce Stock'),
      'parameter' => array(
        'commerce_product' => array(
          'type' => 'commerce_product',
          'label' => t('Product'),
          'save' => TRUE //save the changes after executing the rule
        ),
        'amount' => array(
          'type' => 'integer',
          'label' => t('Amount')
        ),
      ),
    );

    $actions['commerce_stock_adjust_by_order'] = array(
      'label' => t('Adjust the product stock level, given an order'),
      'group' => t('Commerce Stock'),
      'parameter' => array(
        'commerce_order' => array(
          'type' => 'commerce_order',
          'label' => t('Order')
        ),
      ),
    );
  */
  $actions['commerce_stock_decrease_by_line_item'] = array(
    'label' => t('Decrease the product stock level, given a line item'),
    'group' => t('Commerce Stock'),
    'parameter' => array(
      'commerce_line_item' => array(
        'type' => 'commerce_line_item',
        'label' => t('Line item'),
      ),
    ),
  );

  // 'Adjust by line item' was the old name. To avoid breaking existing
  // installations we'll keep a copy around. Sad. Couldn't figure out
  // a way to update it using hook_update_N().
  $actions['commerce_stock_adjust_by_line_item'] = $actions['commerce_stock_decrease_by_line_item'];
  $actions['commerce_stock_adjust_by_line_item']['label'] = t('(legacy) Decrease the product stock level');
  $actions['commerce_stock_increase_by_line_item'] = array(
    'label' => t('Increase the product stock level, given a line item'),
    'group' => t('Commerce Stock'),
    'parameter' => array(
      'commerce_line_item' => array(
        'type' => 'commerce_line_item',
        'label' => t('Line item'),
      ),
    ),
  );
  return $actions;
}