function uc_order_condition_has_products in Ubercart 5
Same name and namespace in other branches
- 8.4 uc_order/uc_order.rules.inc \uc_order_condition_has_products()
- 6.2 uc_order/uc_order.ca.inc \uc_order_condition_has_products()
- 7.3 uc_order/uc_order.rules.inc \uc_order_condition_has_products()
File
- uc_order/
uc_order_workflow.inc, line 359 - This file contains the Workflow-ng 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->nid;
}
$required = array_intersect($settings['products'], $products);
if ($settings['required']) {
$required_check = $required == $settings['products'];
}
else {
$required_check = (bool) count($required);
}
if ($settings['forbidden']) {
$forbidden = array_diff($products, $settings['products']);
$forbidden_check = (bool) count($forbidden);
}
else {
$forbidden_check = false;
}
return $required_check && !$forbidden_check;
}