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