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 ({ eventBus, getApi }) => {
    eventBus.on('basket.initialized', async () => {
        const basketProductsApi = await getApi('basketProductsApi');

        const productsInBasket = basketProductsApi.get();

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

Basket Products API methods reference

Models reference