Skip to content

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