Skip to content

selectPromotionCode$(): Observable<PromotionCode>

The selectPromotionCode$ method allows to select the active promotion code in the basket.

Returned value

A returned value has a type of Observable<PromotionCode | null> representing the promotion code.

Example

In this example we make a basketPromotionsApi call to select the active promotion code in the basket.

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

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

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

    const promotionCode$ = basketPromotionsApi.selectPromotionCode$();
});

Basket Promotions API methods reference

Models reference