function uc_order_condition_count_products in Ubercart 5
Same name and namespace in other branches
- 8.4 uc_order/uc_order.rules.inc \uc_order_condition_count_products()
- 6.2 uc_order/uc_order.ca.inc \uc_order_condition_count_products()
- 7.3 uc_order/uc_order.rules.inc \uc_order_condition_count_products()
File
- uc_order/
uc_order_workflow.inc, line 420 - 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_count_products($order, $settings) {
$totals = array(
'all' => 0,
);
$total = 0;
foreach ($order->products as $product) {
$totals['all'] += $product->qty;
$totals[$product->nid] = $product->qty;
}
if (in_array('all', $settings['products'])) {
$total = $totals['all'];
}
else {
foreach ($settings['products'] as $product) {
$total += $totals[$product];
}
}
switch ($settings['product_count_comparison']) {
case 'less':
return $total < $settings['product_count_value'];
case 'less_equal':
return $total <= $settings['product_count_value'];
case 'equal':
return $total == $settings['product_count_value'];
case 'greater_equal':
return $total >= $settings['product_count_value'];
case 'greater':
return $total > $settings['product_count_value'];
}
}