Skip to main content

Address

Checkout provides built-in address autocomplete for a supported list of countries. These targets let you connect your own address service to extend coverage to additional countries or use a provider your app already integrates with.

  • Expand address coverage: Use an external address service such as Google Places, HERE, or Loqate to provide autocomplete for countries that Shopify doesn't cover by default.
  • Postal code lookup: Return matching addresses when buyers type a postal code, letting them select a result without manually entering their street.
  • Find delivery coordinates: Return latitude and longitude alongside address fields for delivery routing, zone pricing, or time-in-transit estimates.

Use these targets to return address suggestions as buyers type and resolve a selected suggestion into a complete address.

The suggest target is required and runs each time a buyer types in a field. The format-suggestion target is optional and runs when a buyer selects a result. If you use both targets, they must be declared in the same shopify.extension.toml file.

Both targets are JavaScript extensions built with the ui-extensions library. They receive buyer input and return structured data rather than rendering UI components. To learn more, see the address autocomplete tutorial.

purchase.address-autocomplete.suggest

Runs when a buyer types in the first field of the address form, which is either address1 or zip, depending on the buyer's country. The target receives the current input value, field name, and the selected country code when available. Each suggestion you return requires a label and can include matchedSubstrings to highlight matching text in the dropdown.

Include a formattedAddress with each suggestion to populate address fields when a buyer selects one, or include an id so the format-suggestion target can fetch the complete address. You can pass shopify.signal to any fetch calls. The signal aborts when the buyer navigates away from the address field or when the debounced query value changes.

purchase.address-autocomplete.format-suggestion

Formats the suggestion the buyer selected from the purchase.address-autocomplete.suggest target into a complete address. Use this target when your address service returns partial suggestions that require a second request to resolve.

This target receives target.selectedSuggestion, which includes the suggestion's id, label, and any matchedSubstrings from the suggest target. It must return a fully formatted address.


  • Format labels clearly: Return a complete, human-readable address string for each suggestion's label, such as 151 O'Connor St, Ottawa, ON K2P 2L8, Canada. Shopify displays the label exactly as returned and doesn't parse it. Incomplete or abbreviated labels make it difficult for buyers to identify their address in the dropdown.
  • Use a stable id for two-step lookups: If you're using the format-suggestion target, set a stable id on each suggestion that maps to the address in your service. The format-suggestion target receives the full suggestion object, including the id, which you can use to look up and return the complete address.

Was this page helpful?