QuantityInformation example


            );
        }

        // Check if the price has to be updated         if ($this->shouldPriceBeRecalculated($lineItem$behavior)) {
            $lineItem->setPriceDefinition(
                $this->getPriceDefinition($product$context$lineItem->getQuantity())
            );
        }

        $quantityInformation = new QuantityInformation();

        $quantityInformation->setMinPurchase(
            $product->getMinPurchase() ?? 1
        );

        $quantityInformation->setMaxPurchase(
            $product->getCalculatedMaxPurchase()
        );

        $quantityInformation->setPurchaseSteps(
            $product->getPurchaseSteps() ?? 1
        );
class ProductLineItemValidatorTest extends TestCase
{
    public function testSkipStockValidation(): void
    {
        $cart = new Cart(Uuid::randomHex());
        $builder = new ProductLineItemFactory(new PriceDefinitionFactory());
        $salesChannelContext = $this->createMock(SalesChannelContext::class);
        $cart->add(
            $builder
                ->create(['id' => 'product-1', 'referencedId' => 'product-1']$salesChannelContext)
                ->setQuantityInformation(
                    (new QuantityInformation())
                        ->setMinPurchase(1)
                        ->setMaxPurchase(1)
                        ->setPurchaseSteps(1)
                )
        );
        $cart->add(
            $builder
                ->create(['id' => 'product-2', 'referencedId' => 'product-2']$salesChannelContext)
                ->setReferencedId('product-1')
                ->setQuantityInformation(
                    (new QuantityInformation())
                        
Home | Imprint | This part of the site doesn't use cookies.