You are here

function uc_discounts_condition_total in Ubercart Discounts (Alternative) 7.2

Same name and namespace in other branches
  1. 6.2 uc_discounts/uc_discounts.ca.inc \uc_discounts_condition_total()

Check the current order balance minus any discounts.

See also

uc_discounts_condition_total_form()

1 string reference to 'uc_discounts_condition_total'
uc_discounts_ca_condition in uc_discounts/uc_discounts.ca.inc
Implements hook_ca_condition().

File

uc_discounts/uc_discounts.ca.inc, line 87
Conditional action functions for uc_discounts module.

Code

function uc_discounts_condition_total($order, $settings) {
  $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 ($settings['order_total_comparison']) {
    case 'less':
      return $total < $settings['order_total_value'];
    case 'less_equal':
      return $total <= $settings['order_total_value'];
    case 'equal':
      return $total == $settings['order_total_value'];
    case 'greater_equal':
      return $total >= $settings['order_total_value'];
    case 'greater':
      return $total > $settings['order_total_value'];
  }
}