Skip to content

update(product: ProductBasket, quantity: number): void

The update method allows to update the item quantity in basket.

Input parameters

product

product is a mandatory parameter of the ProductBasket type that represents the item we want to update.

quantity

quantity is a mandatory parameter of the number type that represents the new quantity of an item.

Returned value

A returned value has a type of void as this method returns nothing.

Example

In this example we make a basketProductsApi call to update a first item's quantity to 10.

useStorefront(async (storefront) => {
    let basketProductsApi = storefront.getApiSync('basketProductsApi');

    if (!basketProductsApi) {
        const featureSystemApi = this.getApiSync('FeatureSystemApi');
        await featureSystemApi.registerDynamic('basket');

        basketProductsApi = storefront.getApiSync('basketProductsApi');
    }

    const productsInBasket = this._basketProductsApi.get();

    basketProductsApi.update(productsInBasket[0], 10);
});

Basket Products API methods reference

Models reference