Skip to content

selectIsDifferentShippingAddressRequired$(): Observable<boolean>

The selectIsDifferentShippingAddressRequired$ method allows to check if a different shipping address is currently required. It is helpful when we want to show something to the user if they indicate that they want to ship to a different address.

Returned value

A returned value has a type of Observable<boolean> indicating whether a different shipping addresses is currently required or not.

Example

In this example we make a basketAddressesApi call to check if a different shipping address is currently required.

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

        const isDifferentShippingAddressRequired$ = basketAddressesApi.selectIsDifferentShippingAddressRequired$();

        isDifferentShippingAddressRequired$.subscribe((isDifferentShippingAddressRequired) => {
            if (isDifferentShippingAddressRequired) {
                // do something if a different shipping address is required
            }
            else {
                // do something if a different shipping address is not required
            }
        });
    });
});

Basket Address API methods reference