BeforeLineItemQuantityChangedEvent example

if (!isset($data['type'])) {
            $data['type'] = $lineItem->getType();
        }

        $this->validate($data);

        $handler = $this->getHandler($data['type'] ?? '');

        if (isset($data['quantity'])) {
            $lineItem->setQuantity($data['quantity']);

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

        $lineItem->markModified();

        $handler->update($lineItem$data$context);
    }

    private function getHandler(string $type): LineItemFactoryInterface
    {
        foreach ($this->handlers as $handler) {
            if ($handler->supports($type)) {
                
Home | Imprint | This part of the site doesn't use cookies.