Skip to content

remove(product: ProductBasket): void

The remove method allows to remove an item from the basket.

Input parameters

product

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

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 remove a first item from the basket.

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.remove(productsInBasket[0]);
});

Basket Products API methods reference

Models reference