Skip to main content

Order Routing Rule API

Requires the function settings component.

The Order Routing Rule API provides access to order routing rule configuration and settings management. Use this API to build custom configuration interfaces for order routing rules that determine fulfillment locations.

  • Rule configuration: Build custom configuration interfaces for order routing rules.
  • Metafield management: Store and retrieve rule-specific configuration in metafields.
  • Location selection: Configure fulfillment location preferences and routing logic.
  • Settings persistence: Save rule settings that determine fulfillment routing behavior.
Support
Targets (1)

The shopify global object provides access to order routing rule data and configuration. Access the following properties on shopify to interact with the current order routing rule context in the admin.settings.order-routing-rule.render target.

Anchor to applyMetafieldsChange
applyMetafieldsChange
required

Updates or removes metafields that store order routing rule configuration.

required

Provides methods for authenticating calls to your app backend. Use the idToken() method to retrieve a signed JWT token that verifies the current user's identity for secure server-side operations.

required

The order routing rule being configured, including its metadata and associated metafields.

Anchor to extension
extension
{ target: ; }
required

The identifier of the running extension target. Use this to determine which target your extension is rendering in and conditionally adjust functionality or UI based on the extension context.

required

Utilities for translating content according to the current localization of the admin. Use these methods to provide translated strings that match the merchant's language preferences, ensuring your extension is accessible to a global audience.

Anchor to intents
intents
required

Provides information to the receiver of an intent. Use this to access data passed from other extensions or parts of the admin when your extension is launched through intent-based navigation.

Anchor to query
query
< = unknown, Variables = { [key: string]: unknown; }>(query: string, options?: { variables?: Variables; version?: Omit<, "2023-04">; }) => Promise<{ data?: ; errors?: []; }>
required

Executes GraphQL queries against the GraphQL Admin API. Use this to fetch shop data, manage resources, or perform mutations. Queries are automatically authenticated with the current user's permissions. Optionally specify GraphQL variables and API version for your query.

Anchor to storage
storage
required

Provides methods for persisting data in browser storage that is scoped to your extension. Use this to store user preferences, cache data, maintain state across sessions, or save temporary working data. Storage is persistent across page reloads and isolated per extension.


  • Batch metafield changes for atomic updates: applyMetafieldsChange accepts an array of change objects. Pass multiple changes in a single call to ensure all changes succeed or all fail together.
  • Check operation result type: applyMetafieldsChange returns { type: 'success' } or { type: 'error', message: string }. Errors don't throw, so always check the returned type.

  • Metafields have size limits. Individual values can't exceed 256KB, and total metafield storage per rule is limited.
  • Rule priority is read-only. Evaluation order can't be modified through the settings interface. Merchants manage priority through the main rules interface.
  • Batch operations are all-or-nothing. If any metafield change in the array fails validation, the entire batch fails and no changes apply.
  • Metafield changes apply immediately. They persist right away without waiting for merchants to save the rule.

Was this page helpful?