Skip to content

selectHasPromotionCode$(): Observable<boolean>

The selectHasPromotionCode$ method allows to select the information about whether a promotion code is present in the basket or not.

Returned value

A returned value has a type of Observable<boolean> representing whether a promotion code is present in the basket or not.

Example

In this example we make a basketPromotionsApi call to select the information about whether a promotion code is present in the basket or not.

useStorefront(async ({ eventBus, getApi }) => {
    eventBus.on('basket.initialized', async () => {
        const basketPromotionsApi = await getApi('basketPromotionsApi');

        const hasPromotionCode$ = basketPromotionsApi.selectHasPromotionCode$();
    });
});

Basket Promotions API methods reference