Skip to content

getHasPromotionCode(): boolean

The getHasPromotionCode method allows to retrieve the information about whether a promotion code is present in the basket or not.

Returned value

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

Example

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

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

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

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

    const hasPromotionCode = basketPromotionsApi.getHasPromotionCode();
});

Basket Promotions API methods reference