Skip to content

isDifferentShippingAddressRequired(): boolean

The isDifferentShippingAddressRequired method allows to check if a different shipping address is 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 boolean indicating whether a different shipping addresses is required or not.

Example

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

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

        const isDifferentShippingAddressRequired = basketAddressesApi.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