CartFacade example

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

        $cart->setErrors(new ErrorCollection([
            new GenericCartError('foo', 'foo', [], 1, false, false),
        ]));

        $facade = new CartFacade(
            $this->createMock(CartFacadeHelper::class),
            $this->createMock(ScriptPriceStubs::class),
            $cart,
            $this->createMock(SalesChannelContext::class)
        );

        $items = $facade->items();
        static::assertCount(3, $items);
        static::assertTrue($items->has('item'));

        $items = $facade->products();
        
private readonly CartFacadeHelper $helper,
        private readonly ScriptPriceStubs $priceStubs
    ) {
    }

    public function factory(Hook $hook, Script $script): CartFacade
    {
        if (!$hook instanceof CartAware) {
            throw new HookInjectionException($hook, self::class, CartAware::class);
        }

        return new CartFacade($this->helper, $this->priceStubs, $hook->getCart()$hook->getSalesChannelContext());
    }

    /** * @param CartFacade $service */
    public function after(object $service, Hook $hook, Script $script): void
    {
        $service->calculate();
    }

    public function getName(): string
    {
Home | Imprint | This part of the site doesn't use cookies.