function commerce_stock_check_product_rule in Commerce Stock 7.2
Check the stock using rules.
Invokes the rule event and return the result of its action.
1 call to commerce_stock_check_product_rule()
- commerce_stock_add_to_cart_validate in ./
commerce_stock.module - Form validation handler for commerce_cart_add_to_cart_form().
File
- ./
commerce_stock.module, line 397 - Commerce Stock module.
Code
function commerce_stock_check_product_rule($product, &$qty, $qty_ordered, &$stock_state, &$message) {
// Set defaults to the global stock check array.
// @codingStandardsIgnoreLine
global $stock_check_data;
$stock_check_data = array(
'state' => '0',
'message' => '',
'qty' => $qty,
);
// Invoke the stock check event.
rules_invoke_event('commerce_stock_add_to_cart_check_product', $product, $qty, $qty_ordered, $qty + $qty_ordered);
// If state not ok, do nothing then return the value set by the action.
if ($stock_check_data['state'] != 0) {
$stock_state = $stock_check_data['state'];
$message = $stock_check_data['message'];
$qty = $stock_check_data['qty'];
}
}