function uc_order_condition_products_weight in Ubercart 7.3
Same name and namespace in other branches
- 8.4 uc_order/uc_order.rules.inc \uc_order_condition_products_weight()
- 5 uc_order/uc_order_workflow.inc \uc_order_condition_products_weight()
- 6.2 uc_order/uc_order.ca.inc \uc_order_condition_products_weight()
Checks the weight of the order's products.
See also
uc_order_condition_products_weight_form()
1 string reference to 'uc_order_condition_products_weight'
- 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 631 - Hooks and functions for uc_order Rules integration.
Code
function uc_order_condition_products_weight($order, $products, $weight_units, $weight_value, $op) {
$totals = array(
'all' => 0,
);
$total = 0;
foreach ($order->products as $product) {
$unit_conversion = uc_weight_conversion($product->weight_units, $weight_units);
$totals['all'] += $product->qty * $product->weight * $unit_conversion;
$totals[$product->nid] = $product->qty * $product->weight * $unit_conversion;
}
if (in_array('all', $products)) {
$total = $totals['all'];
}
else {
foreach ($products as $product) {
if (isset($totals[$product])) {
$total += $totals[$product];
}
}
}
return uc_order_condition_value_operator_comparison($total, $op, $weight_value);
}