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 (storefront) => {
let basketAddressesApi = storefront.getApiSync('basketAddressesApi');
if (!basketAddressesApi) {
const featureSystemApi = this.getApiSync('FeatureSystemApi');
await featureSystemApi.registerDynamic('basket');
basketAddressesApi = storefront.getApiSync('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¶
- getShippingAddress
- selectShippingAddress$
- setShippingAddress
- getBillingAddress
- selectBillingAddress$
- setBillingAddress
- isBillingAddressEqualShippingAddress
- selectIsBillingAddressEqualShippingAddress$
- selectIsDifferentShippingAddressRequired$
- setBillingAddressAsShippingAddress
- getSectionValidation
- selectSectionValidation$