CartPriceFacade example

new CalculatedTaxCollection(),
            new TaxRuleCollection(),
            CartPrice::TAX_STATE_GROSS,
            99.99
        );

        $stubs = $this->createMock(ScriptPriceStubs::class);
        $price = new PriceCollection([]);

        $stubs->method('build')->willReturn($price);

        $facade = new CartPriceFacade($original$stubs);

        static::assertEquals(100, $facade->getNet());
        static::assertEquals(200, $facade->getTotal());
        static::assertEquals(200, $facade->getRounded());
        static::assertEquals(300, $facade->getPosition());
        static::assertEquals(99.99, $facade->getRaw());

        static::assertSame($price$facade->create([]));
    }
}


    /** * The `price()` method returns the current price of the cart. * Note that this price may be outdated, if you changed something inside the cart in your script. * Use the `calculate()` method to recalculate the cart and update the price. * * @return CartPriceFacade The calculated price of the cart. */
    public function price(): CartPriceFacade
    {
        return new CartPriceFacade($this->cart->getPrice()$this->priceStubs);
    }

    /** * The `errors()` method returns the current errors of the cart. * You can use it to add new errors or warning or to remove existing ones. * * @return ErrorsFacade A `ErrorsFacade` containing all cart errors as a collection (may be an empty collection if there are no errors) */
    public function errors(): ErrorsFacade
    {
        return new ErrorsFacade($this->cart->getErrors());
    }
Home | Imprint | This part of the site doesn't use cookies.