public function OrderPurchasedEntity::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/ OrderPurchasedEntity.php, line 26
Class
- OrderPurchasedEntity
- Provides the variation condition for orders.
Namespace
Drupal\commerce_order\Plugin\Commerce\ConditionCode
public function evaluate(EntityInterface $entity) {
$this
->assertEntity($entity);
assert($entity instanceof OrderInterface);
foreach ($entity
->getItems() as $order_item) {
if ($this
->isValid($order_item
->getPurchasedEntity())) {
return TRUE;
}
}
return FALSE;
}