ProductOutOfStockError example

new PromotionNotFoundError('tn-08'),
                    ]
                ),
                [
                    self::PROMOTION_NOT_FOUND_ERROR_CONTENT,
                ],
            ],
            // Product out of stock             [
                new ErrorCollection(
                    [
                        new ProductOutOfStockError('product id', 'Car'),
                    ]
                ),
                [
                    self::PRODUCT_STOCK_REACHED_ERROR_CONTENT,
                ],
            ],
        ];
    }

    public function testCheckoutCartPageLoadedHookScriptsAreExecuted(): void
    {
        
if ($item->getQuantityInformation() !== null) {
            $minPurchase = $item->getQuantityInformation()->getMinPurchase();
            $available = $item->getQuantityInformation()->getMaxPurchase() ?? 0;
            $steps = $item->getQuantityInformation()->getPurchaseSteps() ?? 1;
        }

        if ($available < $minPurchase) {
            $scope->remove($item->getId());

            $cart->addErrors(
                new ProductOutOfStockError((string) $item->getReferencedId()(string) $item->getLabel())
            );

            return;
        }

        if ($available < $item->getQuantity()) {
            $maxAvailable = $this->fixQuantity($minPurchase$available$steps);

            $item->setQuantity($maxAvailable);

            $cart->addErrors(
                
Home | Imprint | This part of the site doesn't use cookies.