Skip to content

selectBasketPositions$(): Observable<number>

The selectBasketPositions$ method allows to select a number of positions in the basket.

Returned value

A returned value has a type of Observable<number> representing the number of positions in the basket.

Example

In this example we make a basketProductsApi call to select a number of positions in 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 amountOfProductPositionsInBasket$ = this._basketProductsApi.selectBasketPositions$();
});

Basket Products API methods reference