AbsoluteItem example

$context->setTaxState(CartPrice::TAX_STATE_GROSS);
        $context->setItemRounding(new CashRoundingConfig(2, 0.01, true));

        yield 'Remove discounts when cart is empty' => [
            [new PercentageItem(10, self::DISCOUNT_ID)],
            null,
        ];

        yield 'Remove discount when cart gets negative' => [
            [
                new CalculatedItem(10, new HighTaxes()$context),
                new AbsoluteItem(-20, self::DISCOUNT_ID),
            ],
            null,
        ];

        yield 'Remove second discount when cart gets negative' => [
            [
                new CalculatedItem(10, new HighTaxes()$context),
                new AbsoluteItem(-5),
                new AbsoluteItem(-6, self::DISCOUNT_ID),
            ],
            null,
        ];
yield 'Test percentage discount for one item' => [
            new ContainerItem([
                new QuantityItem(20, new HighTaxes()),
                new PercentageItem(-10),
            ]),
            new CalculatedPrice(18, 18, new CalculatedTaxes([19 => 2.87])new HighTaxes()),
        ];

        yield 'Test absolute discount for one item' => [
            new ContainerItem([
                new QuantityItem(20, new HighTaxes()),
                new AbsoluteItem(-10),
            ]),
            new CalculatedPrice(10, 10, new CalculatedTaxes([19 => 1.59])new HighTaxes()),
        ];

        yield 'Test discount calculation for two items' => [
            new ContainerItem([
                new QuantityItem(20, new HighTaxes()),
                new QuantityItem(20, new LowTaxes()),
                new PercentageItem(-10),
            ]),
            new CalculatedPrice(36, 36, new CalculatedTaxes([19 => 2.87, 7 => 1.18])new HighTaxes()),
        ];
Home | Imprint | This part of the site doesn't use cookies.