protected function PromotionSubscriber::getCoupons in Commerce Shipping 8.2
Gets the shipping coupons for the given order.
Parameters
\Drupal\commerce_order\Entity\OrderInterface $order: The order.
string[] $offer_ids: The shipping offer IDs.
Return value
\Drupal\commerce_promotion\Entity\CouponInterface[] The coupons.
1 call to PromotionSubscriber::getCoupons()
- PromotionSubscriber::getPromotions in src/
EventSubscriber/ PromotionSubscriber.php - Gets the display-inclusive shipping promotions for the given order.
File
- src/
EventSubscriber/ PromotionSubscriber.php, line 154
Class
- PromotionSubscriber
- Applies display-inclusive promotions to the calculated shipping rates.
Namespace
Drupal\commerce_shipping\EventSubscriberCode
protected function getCoupons(OrderInterface $order, array $offer_ids) {
$coupons = $order
->get('coupons')
->referencedEntities();
$coupons = array_filter($coupons, function (CouponInterface $coupon) use ($offer_ids) {
return in_array($coupon
->getPromotion()
->getOffer()
->getPluginId(), $offer_ids);
});
return $coupons;
}