ProductsFacade example

return new ItemsFacade($this->cart->getLineItems()$this->priceStubs, $this->helper, $this->context);
    }

    /** * The `product()` method returns all products of the current cart for further manipulation. * Similar to the `items()` method, but the line-items are filtered, to only contain product line items. * * @return ProductsFacade A `ProductsFacade` containing all product line-items in the current cart as a collection. */
    public function products(): ProductsFacade
    {
        return new ProductsFacade($this->cart->getLineItems()$this->priceStubs, $this->helper, $this->context);
    }

    /** * The `calculate()` method recalculates the whole cart. * Use this to get the correct prices after you made changes to the cart. * Note that after calling the `calculate()` all collections (e.g. items(), products()) get new references, * so if you still hold references to things inside the cart, these are outdated after calling `calculate()`. * * The `calculate()` method will be called automatically after your cart script executed. */
    public function calculate(): void
    {
$this->context = $context;
    }

    /** * The `product()` method returns all products inside the current container for further manipulation. * Similar to the `children()` method, but the line-items are filtered, to only contain product line items. * * @return ProductsFacade A `ProductsFacade` containing all product line-items inside the current container as a collection. */
    public function products(): ProductsFacade
    {
        return new ProductsFacade($this->item->getChildren()$this->priceStubs, $this->helper, $this->context);
    }

    /** * Use the `add()` method to add an item to this container. * * @param ItemFacade $item The item that should be added. * * @return ItemFacade The item that was added to the container. * * @example add-container/add-container.twig 12 1 Add a product to the container and reduce the quantity of the original line-item. */
    
Home | Imprint | This part of the site doesn't use cookies.