items example

$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();
        static::assertCount(3, $items);

        $price = $facade->price();
        static::assertEquals(100, $price->getTotal());

        $errors = $facade->errors();
        static::assertCount(1, $errors);

        
static::assertInstanceOf(ItemFacade::class$split);
        $container->add($split);

        $split = $product->take(1);
        static::assertInstanceOf(ItemFacade::class$split);
        $container->add($split);
        $container->discount('my-discount', 'percentage', -10, 'Fanzy discount');

        $surcharge = new PriceCollection([new Price(Defaults::CURRENCY, 2, 2, false)]);
        $container->surcharge('my-surcharge', 'absolute', $surcharge, 'unit test');

        $service->items()->add($container);
        $service->calculate();

        static::assertTrue($service->has('my-container'));
        $container = $service->get('my-container');

        static::assertInstanceOf(ItemFacade::class$container);
        static::assertInstanceOf(PriceFacade::class$container->getPrice());
        static::assertEquals(182, $container->getPrice()->getTotal());
    }

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