Attributes API
The Attributes API provides read-only access to the custom key-value pairs attached to the order. Use this API to read custom attributes attached to the order, such as delivery instructions or gift messages.
This API reads attributes that were set when the order was placed. To store your own custom data on orders, use metafields instead.
Anchor to Use casesUse cases
- Display delivery instructions: Read and display special instructions the buyer provided, such as "Leave at the back door."
- Show gift messages: Display a gift message the buyer attached to their order.
- Process custom data: Access key-value pairs added by other extensions during checkout, such as a preferred delivery date.
Supported targets
- customer-account.
order-status. announcement. render - customer-account.
order-status. block. render - customer-account.
order-status. cart-line-item. render-after - customer-account.
order-status. cart-line-list. render-after - customer-account.
order-status. customer-information. render-after - customer-account.
order-status. fulfillment-details. render-after - customer-account.
order-status. payment-details. render-after - customer-account.
order-status. return-details. render-after - customer-account.
order-status. unfulfilled-items. render-after - customer-account.
order. page. render
Supported targets
- customer-account.
order-status. announcement. render - customer-account.
order-status. block. render - customer-account.
order-status. cart-line-item. render-after - customer-account.
order-status. cart-line-list. render-after - customer-account.
order-status. customer-information. render-after - customer-account.
order-status. fulfillment-details. render-after - customer-account.
order-status. payment-details. render-after - customer-account.
order-status. return-details. render-after - customer-account.
order-status. unfulfilled-items. render-after - customer-account.
order. page. render
Anchor to PropertiesProperties
The shopify global object provides the custom key-value pairs attached to the order. Access the following properties on shopify to read attributes such as delivery instructions, gift messages, or other information the buyer provided during checkout.
- Anchor to attributesattributesattributesSubscribableSignalLike<Attribute[] | undefined>SubscribableSignalLike<Attribute[] | undefined>requiredrequired
The custom key-value pairs attached to the order by the customer or by other extensions during cart or checkout. These are commonly used for delivery instructions, gift messages, or other information the buyer provides. The value is
undefinedif no attributes were set.
SubscribableSignalLike
Represents a reactive signal interface that provides both immediate value access and subscription-based updates. Enables real-time synchronization with changing data through the observer pattern. This interface extends `ReadonlySignalLike` with deprecated fields that are still supported for backwards compatibility.
- current
The current value of the signal. Equivalent to `.value`, accessing this property subscribes to changes when used in a reactive context.
T - destroy
Cleans up the subscription and releases any resources held by this signal. After calling `destroy()`, the signal stops receiving updates from the main thread.
() => Promise<void> - subscribe
Subscribes to value changes and calls the provided function whenever the value updates. Returns an unsubscribe function to clean up the subscription. Use to automatically react to changes in the signal's value.
(fn: (value: T) => void) => () => void - value
The current value of the signal. This property provides immediate access to the current value without requiring subscription setup. Use for one-time value checks or initial setup.
T
Attribute
- key
The identifier for the attribute. Each key must be unique within the set of attributes on the cart or checkout. If you call `applyAttributeChange()` with a key that already exists, then the existing value is replaced.
string - value
The value associated with the attribute key. This is a freeform string that can store any information the buyer or app provides. Attribute values are always strings. To store structured data, serialize it to JSON and parse it when reading.
string
Anchor to Best practicesBest practices
- Look up attributes by key: Attributes are returned as an array of key-value pairs. Use
Array.find()to look up a specific attribute by itskeyproperty.
Anchor to LimitationsLimitations
- There's no metadata about who set an attribute. You can't determine whether an attribute was set by the buyer, a theme, or another extension.