mixedLineItemType example


    public function add($lineItem): void
    {
        $this->validateType($lineItem);

        $exists = $this->get($lineItem->getId());

        if ($exists && $exists->getType() !== $lineItem->getType()) {
            throw CartException::mixedLineItemType($lineItem->getId()$lineItem->getType());
        }

        if ($exists) {
            $exists->setQuantity($lineItem->getQuantity() + $exists->getQuantity());

            return;
        }

        $this->elements[$this->getKey($lineItem)] = $lineItem;
    }

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