You are here

public function PurchaseOrderCustomerApproved::evaluate in Commerce Purchase Order 8

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

src/Plugin/Commerce/Condition/PurchaseOrderCustomerApproved.php, line 24

Class

PurchaseOrderCustomerApproved
Provides the customer approved condition for purchase orders.

Namespace

Drupal\commerce_purchase_order\Plugin\Commerce\Condition

Code

public function evaluate(EntityInterface $entity) {
  $this
    ->assertEntity($entity);

  /** @var \Drupal\commerce_order\Entity\OrderInterface $order */
  $order = $entity;
  $customer = $order
    ->getCustomer();
  return (bool) ($customer
    ->hasField('field_purchase_orders_authorized') && $customer->field_purchase_orders_authorized
    ->first()->value);
}