You are here

function commerce_stock_rules_set_checkout_state in Commerce Stock 7.2

Function to set checkout state.

Rules action: Set the state of the checkout process (called once per an item).

1 string reference to 'commerce_stock_rules_set_checkout_state'
commerce_stock_rules_action_info in ./commerce_stock.rules.inc
Implements hook_rules_action_info().

File

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

Code

function commerce_stock_rules_set_checkout_state($stock_action, $message, $approved_quantity) {
  if ($approved_quantity < 0) {
    $approved_quantity = 0;

    // If zero transaction must be blocked as it you are not allowed
    // to add zero quantity to the cart.
    $stock_action = 1;
  }

  // Set the global stock check array.
  // @codingStandardsIgnoreLine
  global $stock_check_data;
  $stock_check_data['state'] = $stock_action;
  $stock_check_data['message'] = $message;
  $stock_check_data['qty'] = $approved_quantity;
}