blockPromotion example

// remove other discounts of the promotion that should be deleted             $this->removeOtherDiscountsOfPromotion($cart$lineItem$event->getSalesChannelContext());
            $this->removeCode($code$cart);

            return;
        }

        // the user wants to remove an automatic added         // promotions, so lets do this         if ($lineItem->hasPayloadValue('promotionId')) {
            $promotionId = (string) $lineItem->getPayloadValue('promotionId');
            $this->blockPromotion($promotionId$cart);
        }
    }

    /** * @throws CartException */
    private function checkFixedDiscountItems(Cart $cart, LineItem $lineItem): void
    {
        $lineItems = $cart->getLineItems()->filterType(PromotionProcessor::LINE_ITEM_TYPE);
        if ($lineItems->count() < 1) {
            return;
        }
class CartExtensionTest extends TestCase
{
    /** * This test verifies that we can add a promotion * id and it will be found as "blocked" in the extension * * @group promotions */
    public function testPromotionIsBlocked(): void
    {
        $extension = new CartExtension();
        $extension->blockPromotion('abc');

        static::assertTrue($extension->isPromotionBlocked('abc'));
    }

    /** * This test verifies that a non-existing id * is being returned as "not blocked" * * @group promotions */
    public function testDifferentPromotionIsNotBlocked(): void
    {
Home | Imprint | This part of the site doesn't use cookies.