selectIsEveryAvailablePaymentFree$(): Observable<boolean>¶
The selectIsEveryAvailablePaymentFree$
method allows you to observe whether every available payment option is free.
Returned value¶
A returned value has a type of Observable<boolean>
. It emits true
if every available payment option is free; otherwise, it emits false
.
Example¶
In this example, we make a basketShippingsApi
call to observe whether every available payment option is free.
useStorefront(async (storefront) => {
let basketShippingsApi = storefront.getApiSync('basketShippingsApi');
if (!basketShippingsApi) {
const featureSystemApi = this.getApiSync(FEATURE_SYSTEM_API_NAME);
await featureSystemApi.registerDynamic('basket');
basketShippingsApi = storefront.getApiSync('basketShippingsApi');
}
const isEveryPaymentFree$ = basketShippingsApi.selectIsEveryAvailablePaymentFree$();
isEveryPaymentFree$.subscribe((isFree) => {
if (isFree) {
console.log('All available payment options are free.');
} else {
console.log('Some payment options have associated costs.');
}
});
});
Basket Address API methods reference¶
- get
- select
- setShipping
- setPickupPoint
- getSelectedShipping
- selectSelectedShipping
- getAvailableShippingCountries
- selectAvailableShippingCountries
- getSelectedShippingCountry
- selectSelectedShippingCountry
- setCountry
- getPaymentCostForActiveShippingByPaymentId
- selectPaymentCostForActiveShippingByPaymentId
- isEveryAvailablePaymentFree
- getSectionValidation
- selectSectionValidation
- addMap
- showPickupPointMap
- shouldDisplayRemainingBasketValueForFreeShippingMessage
- addShippingInfo
- getShippingInfo