You are here

function uc_discounts_condition_total_after_discounts in Ubercart Discounts (Alternative) 7.2

Check the current order balance minus any discounts.

File

uc_discounts/uc_discounts.rules.inc, line 73
Rules integration for uc_discounts module.

Code

function uc_discounts_condition_total_after_discounts($order, $order_total_value, $operator_comparison) {
  $order->uc_discounts_codes = $_SESSION['uc_discounts_codes'];
  $results = uc_discounts_get_discounts_for_order($order);
  $total_discount = 0;
  foreach ($results['discounts'] as $discount) {
    $total_discount += $discount->amount;
  }
  $total = uc_order_get_total($order, TRUE) - $total_discount;
  switch ($operator_comparison) {
    case 'less':
      return $total < $order_total_value;
    case 'less_equal':
      return $total <= $order_total_value;
    case 'equal':
      return $total == $order_total_value;
    case 'greater_equal':
      return $total >= $order_total_value;
    case 'greater':
      return $total > $order_total_value;
  }
}