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 (storefront) => {
    let basketPromotionsApi = storefront.getApiSync('basketPromotionsApi');

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

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

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

Basket Promotions API methods reference

Models reference