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 (storefront) => {
let basketPromotionsApi = storefront.getApiSync('basketPromotionsApi');
if (!basketPromotionsApi) {
const featureSystemApi = this.getApiSync('FeatureSystemApi');
await featureSystemApi.registerDynamic('basket');
basketPromotionsApi = storefront.getApiSync('basketPromotionsApi');
}
const hasPromotionCode$ = basketPromotionsApi.selectHasPromotionCode$();
});