You are here

uc_stock.rules_defaults.inc in Ubercart 8.4

Same filename and directory in other branches
  1. 7.3 uc_stock/uc_stock.rules_defaults.inc

Rules default configurations for uc_stock.module.

File

uc_stock/uc_stock.rules_defaults.inc
View source
<?php

/**
 * @file
 * Rules default configurations for uc_stock.module.
 */

/**
 * Implements hook_default_rules_configuration().
 */
function uc_stock_default_rules_configuration() {
  $configs = [];
  $rule = rules_reaction_rule();
  $rule->label = t('Decrement stock upon order submission');
  $rule->active = TRUE;
  $rule
    ->event('uc_checkout_complete')
    ->action('uc_stock_action_decrement_stock', [
    'order:select' => 'order',
  ]);
  $configs['uc_stock_decrement_on_order'] = $rule;
  $rule = rules_reaction_rule();
  $rule->label = t('Increment stock on cancelling order');
  $rule->active = FALSE;
  $rule
    ->event('uc_order_status_update')
    ->condition(rules_condition('data_is', [
    'data:select' => 'updated_order:order-status',
    'value' => 'canceled',
  ]))
    ->condition(rules_condition('data_is', [
    'data:select' => 'order:order-status',
    'value' => 'canceled',
  ])
    ->negate())
    ->condition(rules_condition('data_is', [
    'data:select' => 'order:order-status',
    'value' => 'in_checkout',
  ])
    ->negate())
    ->action('uc_stock_action_increment_stock', [
    'order:select' => 'order',
  ]);
  $configs['uc_stock_increment_on_cancel'] = $rule;
  $rule = rules_reaction_rule();
  $rule->label = t('Increment stock on deleting an order');
  $rule->active = FALSE;
  $rule
    ->event('uc_order_delete')
    ->condition(rules_condition('data_is', [
    'data:select' => 'order:order-status',
    'value' => 'canceled',
  ])
    ->negate())
    ->condition(rules_condition('data_is', [
    'data:select' => 'order:order-status',
    'value' => 'in_checkout',
  ])
    ->negate())
    ->action('uc_stock_action_increment_stock', [
    'order:select' => 'order',
  ]);
  $configs['uc_stock_increment_on_delete'] = $rule;
  $rule = rules_reaction_rule();
  $rule->label = t('Decrement stock when order cancellation is being undone');
  $rule->active = FALSE;
  $rule
    ->event('uc_order_status_update')
    ->condition(rules_condition('data_is', [
    'data:select' => 'order:order-status',
    'value' => 'canceled',
  ]))
    ->condition(rules_condition('data_is', [
    'data:select' => 'updated_order:order-status',
    'value' => 'canceled',
  ])
    ->negate())
    ->condition(rules_condition('data_is', [
    'data:select' => 'updated_order:order-status',
    'value' => 'in_checkout',
  ])
    ->negate())
    ->action('uc_stock_action_decrement_stock', [
    'order:select' => 'order',
  ]);
  $configs['uc_stock_decrement_on_uncancel'] = $rule;
  return $configs;
}

Functions

Namesort descending Description
uc_stock_default_rules_configuration Implements hook_default_rules_configuration().