Skip to content

selectIsBillingAddressEqualShippingAddress$(): Observable<boolean>

The selectIsBillingAddressEqualShippingAddress$ method allows to check if the billing address is currently equal to the shipping address.

Returned value

A returned value has a type of Observable<boolean> indicating whether the addresses are currently equal or not.

Example

In this example we make a basketAddressesApi call to check if the billing address is equal to the shipping address.

useStorefront(async ({ eventBus, getApi }) => {
    eventBus.on('basket.initialized', async () => {
        const basketAddressesApi = await getApi('basketAddressesApi');

        const isBillingAddressEqualShippingAddress$ = basketAddressesApi.selectIsBillingAddressEqualShippingAddress$();

        isBillingAddressEqualShippingAddress$.subscribe((isBillingAddressEqualShippingAddress) => {
            if (isBillingAddressEqualShippingAddress) {
                // do something if addresses are equal
            }
            else {
                // do something if addresses are not equal
            }
        });
    });
});

Basket Address API methods reference