public function prepare(StructCollection $definitions, Cart $cart, SalesChannelContext $context, CartBehavior $behavior): void
    {
        $placeholderItemIds = [];

        /** @var array $promotionLineItems */
        $promotionLineItems = $this->getPromotionLineItems($cart);

        // We must not touch any existing items!
        // we do only search for new promotion placeholders and extract their IDs.
        /** @var LineItem $lineItem */
        foreach ($promotionLineItems as $lineItem) {
            if ($this->isPromotionPlaceholder($lineItem)) {
                $placeholderItemIds[] = $lineItem->getKey();
            }
        }

        $definitions->add(new CartPromotionsFetchDefinition($placeholderItemIds));
    }
public function prepare(StructCollection $definitions, Cart $cart, SalesChannelContext $context, CartBehavior $behavior): void
    {
        $placeholderItemIds = [];

        /** @var array $promotionLineItems */
        $promotionLineItems = $this->getPromotionLineItems($cart);

        // We must not touch any existing items!
        // we do only search for new promotion placeholders and extract their IDs.
        /** @var LineItem $lineItem */
        foreach ($promotionLineItems as $lineItem) {
            if ($this->isPromotionPlaceholder($lineItem)) {
                $placeholderItemIds[] = $lineItem->getKey();
            }
        }

        $definitions->add(new CartPromotionsFetchDefinition($placeholderItemIds));
    }
public function prepare ( StructCollection $ definitions , Cart $ cart , SalesChannelContext $ context , CartBehavior $ behavior ) : void { $ placeholderItemIds = [ ] ; /** @var array $promotionLineItems */ $ promotionLineItems = $ this -> getPromotionLineItems ( $ cart ) ; // We must not touch any existing items! // we do only search for new promotion placeholders and extract their IDs. /** @var LineItem $lineItem */ foreach ( $ promotionLineItems as $ lineItem ) { if ( $ this -> isPromotionPlaceholder ( $ lineItem ) ) { $ placeholderItemIds [ ] = $ lineItem -> getKey ( ) ; } } $ definitions -> add ( new CartPromotionsFetchDefinition ( $ placeholderItemIds ) ) ; }
This function extracts all place holder promotion items from
the cart and makes sure they get converted into real promotion line items later.
Only these codes along with all automatic non-code promotions will be
loaded later when collecting the eligible promotions.
This function extracts all place holder promotion items from the cart and makes sure they get converted into real promotion line items later . Only these codes along with all automatic non - code promotions will be loaded later when collecting the eligible promotions .