You are here

function commerce_physical_rules_order_weight_comparison in Commerce Physical Product 7

Calculates the order's total weight and performs a comparison on it.

File

./commerce_physical.rules.inc, line 150
Rules integration for commerce physical.

Code

function commerce_physical_rules_order_weight_comparison($order, $operator, $value, $unit) {
  $order_weight = commerce_physical_order_weight($order, $unit);
  switch ($operator) {
    case '<':
      return $order_weight['weight'] < $value;
    case '<=':
      return $order_weight['weight'] <= $value;
    case '==':
      return $order_weight['weight'] == $value;
    case '>=':
      return $order_weight['weight'] >= $value;
    case '>':
      return $order_weight['weight'] > $value;
  }
  return FALSE;
}