Skip to main content

Buyer Journey API

The Buyer Journey API lets your extension intercept and validate the buyer's progress through checkout. Use this API to block checkout navigation with targeted error messages, check the current journey step, and enforce custom validation rules.

Blocking requires a capability

To block the buyer journey, you must declare the block_progress capability in your extension's shopify.extension.toml configuration.

  • Validate a checkout field: Intercept progress and display an error underneath a specific field, such as the shipping country.
  • Block progress at the page level: Prevent the buyer from continuing and show a page-level error when a condition isn't met.
  • Enforce item quantity limits: Block progress from a cart line item extension when a product exceeds its purchase limit.
Support
Targets (31)

The shopify global object provides buyer journey data for the current checkout. Access the following properties on shopify to read journey state and intercept navigation. Available to purchase extension targets.

Anchor to buyerJourney
buyerJourney
required

Provides details on the buyer's progression through the checkout and lets you intercept navigation to validate data before the buyer continues.

Refer to buyer journey examples for more information.

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.

Installs a function for intercepting and preventing progress on checkout. To block checkout progress, you must set the block_progress capability in your extension's configuration. If you do, then you're expected to inform the buyer why navigation was blocked, either by passing validation errors to the checkout UI or rendering the errors in your extension. useBuyerJourneyIntercept() should be called at the top level of the extension, not within an embedded or child component, to avoid errors should the child component get destroyed. It is good practice to show a warning in the checkout and accounts editor when the merchant has not given permission for your extension to block checkout progress.

Anchor to interceptor
interceptor
required


  • Always check canBlockProgress: The canBlockProgress parameter passed to your intercept callback indicates whether blocking is currently allowed. Respect this flag to avoid unexpected behavior.
  • Target specific fields when possible: Use the target property in error objects to surface errors directly underneath the relevant field, rather than displaying a page-level error. Refer to the target property above for information on the correct path syntax.
  • Use page-level errors only for cart-wide issues: Omit the target property when the error applies to the entire checkout rather than a specific field, such as an unmet order minimum or a missing cart-level requirement.
  • Warn about misconfigured capabilities in the editor: Check useExtensionCapability('block_progress') and shopify.extension.editor to display a warning banner when the capability isn't enabled in the checkout and accounts editor.

  • Validation errors are cleared automatically when the buyer retries. Your extension can't persist errors across navigation attempts.

Was this page helpful?