public function OrderCurrency::evaluate in Commerce Core 8.2
Evaluates the condition.
Parameters
\Drupal\Core\Entity\EntityInterface $entity: The entity.
Return value
bool TRUE if the condition has been met, FALSE otherwise.
Overrides ConditionInterface::evaluate
File
- modules/
order/ src/ Plugin/ Commerce/ Condition/ OrderCurrency.php, line 62
Class
- OrderCurrency
- Provides the currency condition for orders.
Namespace
Drupal\commerce_order\Plugin\Commerce\ConditionCode
public function evaluate(EntityInterface $entity) {
$this
->assertEntity($entity);
/** @var \Drupal\commerce_order\Entity\OrderInterface $order */
$order = $entity;
$total_price = $order
->getTotalPrice();
$order_currency = $total_price ? $total_price
->getCurrencyCode() : '';
return in_array($order_currency, $this->configuration['currencies']);
}