function uc_order_condition_has_products in Ubercart 6.2
Same name and namespace in other branches
- 8.4 uc_order/uc_order.rules.inc \uc_order_condition_has_products()
- 5 uc_order/uc_order_workflow.inc \uc_order_condition_has_products()
- 7.3 uc_order/uc_order.rules.inc \uc_order_condition_has_products()
Check that the order has the selected combination of products.
See also
uc_order_condition_has_products_form()
2 string references to 'uc_order_condition_has_products'
- uc_order_6013_condition_helper in uc_order/
uc_order.install - uc_order_ca_condition in uc_order/
uc_order.ca.inc - Implements hook_ca_condition().
File
- uc_order/
uc_order.ca.inc, line 641 - This file contains the Conditional Actions hooks and functions necessary to make the order related entity, conditions, events, and actions work.
Code
function uc_order_condition_has_products($order, $settings) {
$products = array();
foreach ($order->products as $product) {
$products[] = $product->model;
}
$required = array_intersect($settings['products'], $products);
if (isset($settings['required']) && $settings['required']) {
$required_check = $required == $settings['products'];
}
else {
$required_check = (bool) count($required);
}
if (isset($settings['forbidden']) && $settings['forbidden']) {
$forbidden = array_diff($products, $settings['products']);
$forbidden_check = (bool) count($forbidden);
}
else {
$forbidden_check = FALSE;
}
return $required_check && !$forbidden_check;
}