Affected by promotion
This module provides a service to retrieve entities associated with a promotion. It allows developers to query for specific types of entities that a promotion applies to. This functionality can be integrated into offer type plugins by implementing a specific interface.
Provides a service to give you the entities that are affected by a promotion.
If your offer type supports it, you can do stuff like this:
/** @var \Drupal\affected_by_promotion\AffectedEntitiesManager $mng */
$mng = \Drupal::service('affected_by_promotion.affected_entities_manager');
/** @var \Drupal\Core\Database\Query\SelectInterface $q */
$q = $mng->getAffectedEntitiesQuery($promotion, 'commerce_product');
$products = $q->execute();
For your offer type plugin to support it, it has to implement the following interface:
\Drupal\affected_by_promotion\SupportsAffectedEntitiesQueryInterface
Which has the following method:
public function getAffectedEntitiesQuery($entity_type_id);
There is also an issue to get this into commerce: https://www.drupal.org/project/commerce/issues/3007070
Depends on
Dependencies of the latest stable release
- Commerce Core commerce_promotion
Required by
Tracked projects that depend on this one
No tracked projects depend on this one yet.
Activity
Releases
| Version | Type | Core | Notes | Release date | |
|---|---|---|---|---|---|
| 8.x-1.5 | Stable | 8–11 | Allow D11 | Mar 19, 2026 |