You are here

protected function OrderSubtotalCondition::doEvaluate in Ubercart 8.4

Compares order subtotal.

Parameters

\Drupal\uc_order\OrderInterface $order: The order to check.

string $op: The comparison operator.

float $value: The target value.

Return value

bool TRUE if the order subtotal meets the specified condition.

File

uc_order/src/Plugin/Condition/OrderSubtotalCondition.php, line 54

Class

OrderSubtotalCondition
Provides 'Order subtotal amount' condition.

Namespace

Drupal\uc_order\Plugin\Condition

Code

protected function doEvaluate(OrderInterface $order, $op, $value) {
  if (is_array($order->line_items)) {
    foreach ($order->line_items as $line_item) {
      if ($line_item['type'] == 'subtotal') {
        $subtotal = $line_item['amount'];
        return $this
          ->compareComparisonOptions($subtotal, $op, $value);
      }
    }
  }
  return FALSE;
}