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

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

Basket Promotions API methods reference

Models reference