You are here

function uc_stock_ca_predicate in Ubercart 6.2

Implements hook_ca_predicate().

File

uc_stock/uc_stock.ca.inc, line 16
This file contains all the Workflow-NG hooks that are necessary for Workflow integeration with the uc_stock module

Code

function uc_stock_ca_predicate() {
  $predicates['uc_stock_decrement_on_order'] = array(
    '#title' => t('Decrement stock upon order submission'),
    '#trigger' => 'uc_checkout_complete',
    '#class' => 'uc_stock',
    '#status' => 1,
    '#actions' => array(
      array(
        '#name' => 'uc_stock_action_decrement_stock',
        '#title' => t('Decrement stock of products in order'),
        '#argument_map' => array(
          'order' => 'order',
        ),
      ),
    ),
  );
  $predicates['uc_stock_increment_on_cancel'] = array(
    '#title' => t('Increment stock on cancelling order'),
    '#trigger' => 'uc_order_status_update',
    '#conditions' => array(
      '#operator' => 'AND',
      '#conditions' => array(
        array(
          '#name' => 'uc_order_status_condition',
          '#title' => t('If the order status is Cancelled.'),
          '#argument_map' => array(
            'order' => 'updated_order',
          ),
          '#settings' => array(
            'order_status' => 'canceled',
          ),
        ),
        array(
          '#name' => 'uc_order_status_condition',
          '#title' => t('If the order status wasn\'t Canceled.'),
          '#argument_map' => array(
            'order' => 'order',
          ),
          '#settings' => array(
            'order_status' => 'canceled',
            'negate' => TRUE,
          ),
        ),
        array(
          '#name' => 'uc_order_status_condition',
          '#title' => t('If the order status wasn\'t In Checkout.'),
          '#argument_map' => array(
            'order' => 'order',
          ),
          '#settings' => array(
            'order_status' => 'in_checkout',
            'negate' => TRUE,
          ),
        ),
      ),
    ),
    '#class' => 'uc_stock',
    '#status' => 0,
    '#actions' => array(
      array(
        '#name' => 'uc_stock_action_increment_stock',
        '#title' => t('Increment stock of products in order'),
        '#argument_map' => array(
          'order' => 'order',
        ),
      ),
    ),
  );
  $predicates['uc_stock_increment_on_delete'] = array(
    '#title' => t('Increment stock on deleting an order'),
    '#trigger' => 'uc_order_delete',
    '#conditions' => array(
      '#operator' => 'AND',
      '#conditions' => array(
        array(
          '#name' => 'uc_order_status_condition',
          '#title' => t('If the order status wasn\'t Canceled.'),
          '#argument_map' => array(
            'order' => 'order',
          ),
          '#settings' => array(
            'order_status' => 'canceled',
            'negate' => TRUE,
          ),
        ),
        array(
          '#name' => 'uc_order_status_condition',
          '#title' => t('If the order status wasn\'t In Checkout.'),
          '#argument_map' => array(
            'order' => 'order',
          ),
          '#settings' => array(
            'order_status' => 'in_checkout',
            'negate' => TRUE,
          ),
        ),
      ),
    ),
    '#class' => 'uc_stock',
    '#status' => 0,
    '#actions' => array(
      array(
        '#name' => 'uc_stock_action_increment_stock',
        '#title' => t('Increment stock of products in order'),
        '#argument_map' => array(
          'order' => 'order',
        ),
      ),
    ),
  );
  $predicates['uc_stock_decrement_on_uncancel'] = array(
    '#title' => t('Decrement stock when order cancellation is being undone'),
    '#trigger' => 'uc_order_status_update',
    '#conditions' => array(
      '#operator' => 'AND',
      '#conditions' => array(
        array(
          '#name' => 'uc_order_status_condition',
          '#title' => t('If the order status was Canceled.'),
          '#argument_map' => array(
            'order' => 'order',
          ),
          '#settings' => array(
            'order_status' => 'canceled',
          ),
        ),
        array(
          '#name' => 'uc_order_status_condition',
          '#title' => t('If the order status isn\'t Canceled.'),
          '#argument_map' => array(
            'order' => 'updated_order',
          ),
          '#settings' => array(
            'order_status' => 'canceled',
            'negate' => TRUE,
          ),
        ),
        array(
          '#name' => 'uc_order_status_condition',
          '#title' => t('If the order status isn\'t In Checkout.'),
          '#argument_map' => array(
            'order' => 'updated_order',
          ),
          '#settings' => array(
            'order_status' => 'in_checkout',
            'negate' => TRUE,
          ),
        ),
      ),
    ),
    '#class' => 'uc_stock',
    '#status' => 0,
    '#actions' => array(
      array(
        '#name' => 'uc_stock_action_decrement_stock',
        '#title' => t('Decrement stock of products in order'),
        '#argument_map' => array(
          'order' => 'order',
        ),
      ),
    ),
  );
  return $predicates;
}