Skip to content

setBillingAddressAsShippingAddress(): Promise<void>

The setBillingAddressAsShippingAddress is an asynchronous method which allows to set a billing address to the same value as the shipping address.

Returned value

A returned value has a type of Promise<void> as this method does not return anything.

Example

In this example we make a basketAddressesApi call to set a billing address to the value of the shipping address in the basket.

useStorefront(async (storefront) => {
    let basketAddressesApi = storefront.getApiSync('basketAddressesApi');

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

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

    await basketAddressesApi.setBillingAddressAsShippingAddress();
});

Basket Address API methods reference