How to get all available promotions, which apply to specific product?


You can do it via commerce_order.price_calculator service:

$context = new Context($this->currentUser, $this->currentStore->getStore(), NULL, [
    'field_name' => $items->getName(),
/** @var \Drupal\commerce\PurchasableEntityInterface $purchasable_entity */
$purchasable_entity = $items->getEntity();
$adjustment_types = array_filter($this->getSetting('adjustment_types'));
$result = $this->priceCalculator->calculate($purchasable_entity, 1, $context, $adjustment_types);

//Get promotions
$promos = $result->getAdjustments();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.