Skip to main content

Localized Fields API

Requires access to protected customer data for some properties.

The Localized Fields API provides access to country-specific checkout fields, such as tax credentials and regional identifiers. Use this API to display localized field values, validate them before the buyer proceeds, and surface field-specific error messages.

Localized fields are available only when the merchant has configured them for the buyer's country. useLocalizedField returns undefined when no field is configured. The set of available fields varies by country and Shopify's regional requirements. Extensions can't add custom localized fields.

  • Validate localized fields: Check that country-specific fields like tax IDs meet length or format requirements before the buyer proceeds.
  • Display country-specific values: Show the current value of a localized field or use it in checkout calculations.
  • Display field-specific errors: Surface validation errors directly underneath the relevant localized field to guide the buyer.
Support
Targets (31)

The shopify global object provides localized field data for the current checkout. Access the following properties on shopify to read country-specific checkout fields. Available to purchase extension targets.

Anchor to localizedFields
localizedFields
<[]>

Additional region-specific fields required during checkout, such as tax identification numbers (Brazil's CPF/CNPJ) or customs credentials. The property is available only if the extension has access to protected customer data. The array is empty if the current checkout doesn't require any localized fields.

Anchor to Available Preact hooksAvailable Preact hooks

The following Preact hooks provide a convenience wrapper that makes it easier to perform common tasks without writing your own logic.

The useLocalizedFields hook returns the current localized fields and re-renders your component when the values change. Pass an optional array of keys to filter the results.

[]

[]

The useLocalizedField hook returns a single localized field for the specified key, or undefined if the field isn't available. Re-renders your component when the value changes.

required

| undefined

  • Use the field's title in error messages: The title property provides the localized, human-readable name of the field. Include it in validation errors so the buyer understands which field needs attention.
  • Check field availability before accessing values: Localized fields depend on the buyer's country. Always verify that useLocalizedField returns a value before accessing its properties.

Was this page helpful?