Skip to main content

Addresses API

Requires level 2 access to protected customer data.

The Addresses API provides access to the buyer's shipping and billing addresses during checkout. Use this API to display address details, show location-specific information, and update the shipping address.

The billing address is read-only. There's no method to modify it from an extension. shippingAddress is undefined when the cart contains only digital products or delivery isn't required.

  • Display the shipping destination: Show the buyer's city, province, and country to confirm their shipping location.
  • Show billing information: Display the billing address to confirm the buyer's payment details.
  • Modify the shipping address: Update the shipping address programmatically, such as pre-filling a postal code or correcting a field.
Support
Targets (33)

The shopify global object provides address data for the current checkout. Access the following properties on shopify to read the buyer's addresses. Available to purchase extension targets.

Anchor to billingAddress
billingAddress
< | undefined>

The proposed customer billing address. The address updates when the field is committed (on change) rather than every keystroke. The property is available only if the extension has access to protected customer data. The subscribable value is undefined if the billing address hasn't been provided yet.

Requires access to protected customer data.

Anchor to shippingAddress
shippingAddress
< | undefined>

The proposed customer shipping address. During the information step, the address updates when the field is committed (on change) rather than every keystroke. The property is available only if the extension has access to protected customer data. When available, the subscribable value is undefined if delivery isn't required.

Requires access to protected customer data.

The shopify global object provides methods to modify address data. Access the following methods on shopify to apply shipping address changes. Available to purchase.checkout extension targets.

Anchor to applyShippingAddressChange
applyShippingAddressChange
(change: ) => Promise<>

Updates the buyer's shipping address on the checkout. The provided fields are merged into the existing address without prompting the buyer. On success, the shippingAddress property updates to reflect the change.

Note

This method returns an error if the cart instruction delivery.canSelectCustomAddress is false, or the buyer is using an accelerated checkout method, such as Apple Pay or Google Pay.

Requires access to protected customer data.


  • Preserve buyer input with partial updates: When updating the shipping address, include only the fields you need to change. Unspecified fields keep their current values, so you don't accidentally clear what the buyer already entered.
  • Hide mutation UI when changes are blocked: Check delivery.canSelectCustomAddress via the Cart Instructions API before rendering address modification controls. If it's false, hide the feature entirely rather than showing an error after the buyer interacts with it.

  • Shipping address changes aren't available when the buyer uses an accelerated checkout method such as Apple Pay or Google Pay.

Was this page helpful?