BeforeLineItemRemovedEvent example

foreach ($ids as $id) {
            $lineItem = $cart->get($id);

            if (!$lineItem) {
                throw CartException::lineItemNotFound($id);
            }
            $lineItems[] = $lineItem;

            $cart->remove($id);

            $this->eventDispatcher->dispatch(new BeforeLineItemRemovedEvent($lineItem$cart$context));

            $cart->markModified();
        }

        $cart = $this->cartCalculator->calculate($cart$context);
        $this->cartPersister->save($cart$context);

        $this->eventDispatcher->dispatch(new AfterLineItemRemovedEvent($lineItems$cart$context));

        $this->eventDispatcher->dispatch(new CartChangedEvent($cart$context));

        
Home | Imprint | This part of the site doesn't use cookies.