AfterLineItemAddedEvent example

$alreadyExists = $cart->has($item->getId());
            $cart->add($item);

            $this->eventDispatcher->dispatch(new BeforeLineItemAddedEvent($item$cart$context$alreadyExists));
        }

        $cart->markModified();

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

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

        return new CartResponse($cart);
    }
}
Home | Imprint | This part of the site doesn't use cookies.