Skip to content

isBillingAddressEqualShippingAddress(): boolean

The isBillingAddressEqualShippingAddress method allows to check if the billing address is equal to the shipping address.

Returned value

A returned value has a type of boolean indicating whether the addresses are 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 (storefront) => {
    let basketAddressesApi = storefront.getApiSync('basketAddressesApi');

    if (!basketAddressesApi) {
        const featureSystemApi = this.getApiSync('FeatureSystemApi');
        await featureSystemApi.registerDynamic('basket');

        basketAddressesApi = storefront.getApiSync('basketAddressesApi');
    }

    const isBillingAddressEqualShippingAddress = basketAddressesApi.isBillingAddressEqualShippingAddress();

    if (isBillingAddressEqualShippingAddress) {
        // do something if addresses are equal
    }
    else {
        // do something if addresses are not equal
    }
});

Basket Address API methods reference