Commit 6fc1ccb7 authored by bojanz's avatar bojanz

Product's order item conditions should refer to $purchased_entity.

parent fea80946
......@@ -62,14 +62,14 @@ class OrderItemProduct extends ConditionBase implements ContainerFactoryPluginIn
$this->assertEntity($entity);
/** @var \Drupal\commerce_order\Entity\OrderItemInterface $order_item */
$order_item = $entity;
/** @var \Drupal\commerce_product\Entity\ProductVariationInterface $purchasable_entity */
$purchasable_entity = $order_item->getPurchasedEntity();
if (!$purchasable_entity || $purchasable_entity->getEntityTypeId() != 'commerce_product_variation') {
/** @var \Drupal\commerce_product\Entity\ProductVariationInterface $purchased_entity */
$purchased_entity = $order_item->getPurchasedEntity();
if (!$purchased_entity || $purchased_entity->getEntityTypeId() != 'commerce_product_variation') {
return FALSE;
}
$product_ids = array_column($this->configuration['products'], 'product_id');
return in_array($purchasable_entity->getProductId(), $product_ids);
return in_array($purchased_entity->getProductId(), $product_ids);
}
}
......@@ -27,12 +27,12 @@ class OrderItemProductType extends ConditionBase {
$this->assertEntity($entity);
/** @var \Drupal\commerce_order\Entity\OrderItemInterface $order_item */
$order_item = $entity;
/** @var \Drupal\commerce_product\Entity\ProductVariationInterface $purchasable_entity */
$purchasable_entity = $order_item->getPurchasedEntity();
if (!$purchasable_entity || $purchasable_entity->getEntityTypeId() != 'commerce_product_variation') {
/** @var \Drupal\commerce_product\Entity\ProductVariationInterface $purchased_entity */
$purchased_entity = $order_item->getPurchasedEntity();
if (!$purchased_entity || $purchased_entity->getEntityTypeId() != 'commerce_product_variation') {
return FALSE;
}
$product_type = $purchasable_entity->getProduct()->bundle();
$product_type = $purchased_entity->getProduct()->bundle();
return in_array($product_type, $this->configuration['product_types']);
}
......
......@@ -27,13 +27,13 @@ class OrderItemVariationType extends ConditionBase {
$this->assertEntity($entity);
/** @var \Drupal\commerce_order\Entity\OrderItemInterface $order_item */
$order_item = $entity;
/** @var \Drupal\commerce_product\Entity\ProductVariationInterface $purchasable_entity */
$purchasable_entity = $order_item->getPurchasedEntity();
if (!$purchasable_entity || $purchasable_entity->getEntityTypeId() != 'commerce_product_variation') {
/** @var \Drupal\commerce_product\Entity\ProductVariationInterface $purchased_entity */
$purchased_entity = $order_item->getPurchasedEntity();
if (!$purchased_entity || $purchased_entity->getEntityTypeId() != 'commerce_product_variation') {
return FALSE;
}
return in_array($purchasable_entity->bundle(), $this->configuration['variation_types']);
return in_array($purchased_entity->bundle(), $this->configuration['variation_types']);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment