protected function PaymentBalanceCondition::doEvaluate in Ubercart 8.4
Condition: Check the current order balance.
Parameters
\Drupal\uc_order\OrderInterface $order: The order to check.
string $balance_comparison: What kind of comparison to make.
bool $include_authorizations: Whether to include "authorization only" payments in the comparison.
Return value
bool TRUE if the order total meets the specified condition.
File
- payment/
uc_payment/ src/ Plugin/ Condition/ PaymentBalanceCondition.php, line 84
Class
- PaymentBalanceCondition
- Provides 'Order payment balance' condition.
Namespace
Drupal\uc_payment\Plugin\ConditionCode
protected function doEvaluate(OrderInterface $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;
}
}