function uc_order_condition_has_products in Ubercart 7.3
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()
- 6.2 uc_order/uc_order.ca.inc \uc_order_condition_has_products()
Checks that the order has the selected combination of products.
1 string reference to 'uc_order_condition_has_products'
- uc_order_rules_condition_info in uc_order/
uc_order.rules.inc - Implements hook_rules_condition_info().
File
- uc_order/
uc_order.rules.inc, line 535 - Hooks and functions for uc_order Rules integration.
Code
function uc_order_condition_has_products($order, $products, $required, $forbidden) {
$order_products = array();
foreach ($order->products as $product) {
$order_products[] = $product->model;
}
$required_products = array_intersect($products, $order_products);
if ($required) {
$required_check = $required_products == $products;
}
else {
$required_check = (bool) count($required_products);
}
if ($forbidden) {
$forbidden_products = array_diff($order_products, $products);
$forbidden_check = (bool) count($forbidden_products);
}
else {
$forbidden_check = FALSE;
}
return $required_check && !$forbidden_check;
}