You are here

function uc_payment_condition_order_balance in Ubercart 7.3

Same name and namespace in other branches
  1. 6.2 payment/uc_payment/uc_payment.ca.inc \uc_payment_condition_order_balance()

Condition: Check the current order balance.

1 string reference to 'uc_payment_condition_order_balance'
uc_payment_rules_condition_info in payment/uc_payment/uc_payment.rules.inc
Implements hook_rules_condition_info().

File

payment/uc_payment/uc_payment.rules.inc, line 67
Rules definitions.

Code

function uc_payment_condition_order_balance($order, $balance_comparison, $include_authorizations) {
  $balance = uc_payment_balance($order);
  if ($include_authorizations) {
    foreach ((array) $order->data['cc_txns']['authorizations'] as $auth_id => $data) {
      $balance -= $data['amount'];
    }
  }
  switch ($balance_comparison) {
    case 'less':
      return $balance < 0;
    case 'less_equal':
      return $balance <= 0.01;
    case 'equal':
      return $balance < 0.01 && $balance > -0.01;
    case 'greater':
      return $balance >= 0.01;
  }
}