Skip to content

getPromotionCode(): PromotionCode | null

The getPromotionCode method allows to retrieve the active promotion code in the basket.

Returned value

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

Example

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

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

        const promotionCode = basketPromotionsApi.getPromotionCode();
    });
});

Basket Promotions API methods reference

Models reference