Metafields
The API for interacting with metafields.
Anchor to standardapiStandardApi
The base API object provided to purchase, and customer-account.order-status extension targets.
- Anchor to appMetafieldsappMetafieldsappMetafieldsStatefulRemoteSubscribable<AppMetafieldEntry[]>StatefulRemoteSubscribable<AppMetafieldEntry[]>requiredrequired
The metafields requested in the
shopify.extension.tomlfile. These metafields are updated when there's a change in the merchandise items being purchased by the customer.Requires access to protected customer data.
TipCart metafields are only available on carts created via the Storefront API version
2023-04or later.*Tip:Cart metafields are only available on carts created via the Storefront API version
2023-04or later.*Tip: Cart metafields are only available on carts created via the Storefront API version <code>2023-04</code> or later.*
- Anchor to metafieldsmetafieldsmetafieldsStatefulRemoteSubscribable<Metafield[]>StatefulRemoteSubscribable<Metafield[]>requiredrequired
The metafields that apply to the current checkout.
Metafields are stored locally on the client and are applied to the order object after the checkout completes.
These metafields are shared by all extensions running on checkout, and persist for as long as the customer is working on this checkout.
Once the order is created, you can query these metafields using the GraphQL Admin API
AppMetafieldEntry
A metafield associated with the shop or a resource on the checkout.
- target
The target that is associated to the metadata. {% include /apps/checkout/privacy-icon.md %} Requires access to [protected customer data](/docs/apps/store/data-protection/protected-customer-data) when the type is `customer`, `company` or `companyLocation`.
AppMetafieldEntryTarget - metafield
The metadata information.
AppMetafield
AppMetafieldEntryTarget
The metafield owner.
- type
The type of the metafield owner. {% include /apps/checkout/privacy-icon.md %} Requires access to [protected customer data](/docs/apps/store/data-protection/protected-customer-data) when the type is `customer`, `company` or `companyLocation`.
"cart" | "shop" | "customer" | "product" | "shopUser" | "variant" | "company" | "companyLocation" - id
The numeric owner ID that is associated with the metafield.
string
AppMetafield
Represents a custom metadata attached to a resource.
- key
The key name of a metafield.
string - namespace
The namespace for a metafield.
string - value
The value of a metafield.
string | number | boolean - valueType
The metafield’s information type.
"string" | "boolean" | "integer" | "json_string" | "float" - type
The metafield's type name.
string
Metafield
Metadata associated with the checkout.
- key
The name of the metafield. It must be between 3 and 30 characters in length (inclusive).
string - namespace
A container for a set of metafields. You need to define a custom namespace for your metafields to distinguish them from the metafields used by other apps. This must be between 2 and 20 characters in length (inclusive).
string - value
The information to be stored as metadata.
string | number - valueType
The metafield’s information type.
"string" | "integer" | "json_string"
Returns the metafields configured with shopify.extension.toml.
Anchor to useAppMetafields-parametersParameters
- Anchor to filtersfiltersfiltersAppMetafieldFiltersAppMetafieldFiltersDefault: {}Default: {}
AppMetafieldFilters
- id
string - type
"shop" | "customer" | "product" | "shopUser" | "variant" | "company" | "companyLocation" | "cart" - namespace
string - key
string
AppMetafieldEntry
A metafield associated with the shop or a resource on the checkout.
- target
The target that is associated to the metadata. {% include /apps/checkout/privacy-icon.md %} Requires access to [protected customer data](/docs/apps/store/data-protection/protected-customer-data) when the type is `customer`, `company` or `companyLocation`.
AppMetafieldEntryTarget - metafield
The metadata information.
AppMetafield
AppMetafieldEntryTarget
The metafield owner.
- type
The type of the metafield owner. {% include /apps/checkout/privacy-icon.md %} Requires access to [protected customer data](/docs/apps/store/data-protection/protected-customer-data) when the type is `customer`, `company` or `companyLocation`.
"cart" | "shop" | "customer" | "product" | "shopUser" | "variant" | "company" | "companyLocation" - id
The numeric owner ID that is associated with the metafield.
string
AppMetafield
Represents a custom metadata attached to a resource.
- key
The key name of a metafield.
string - namespace
The namespace for a metafield.
string - value
The value of a metafield.
string | number | boolean - valueType
The metafield’s information type.
"string" | "boolean" | "integer" | "json_string" | "float" - type
The metafield's type name.
string
Returns a single filtered Metafield or undefined.
Anchor to useMetafield-parametersParameters
- Anchor to filtersfiltersfiltersMetafieldFilterMetafieldFilterrequiredrequired
MetafieldFilter
- namespace
string - key
string
Metafield
Metadata associated with the checkout.
- key
The name of the metafield. It must be between 3 and 30 characters in length (inclusive).
string - namespace
A container for a set of metafields. You need to define a custom namespace for your metafields to distinguish them from the metafields used by other apps. This must be between 2 and 20 characters in length (inclusive).
string - value
The information to be stored as metadata.
string | number - valueType
The metafield’s information type.
"string" | "integer" | "json_string"
Returns the current array of metafields applied to the checkout. You can optionally filter the list.
Anchor to useMetafields-parametersParameters
- Anchor to filtersfiltersfiltersMetafieldsFiltersMetafieldsFilters
MetafieldsFilters
- namespace
string - key
string
Metafield
Metadata associated with the checkout.
- key
The name of the metafield. It must be between 3 and 30 characters in length (inclusive).
string - namespace
A container for a set of metafields. You need to define a custom namespace for your metafields to distinguish them from the metafields used by other apps. This must be between 2 and 20 characters in length (inclusive).
string - value
The information to be stored as metadata.
string | number - valueType
The metafield’s information type.
"string" | "integer" | "json_string"
Anchor to checkoutapiCheckoutApi
The API object provided to purchase.checkout extension targets.
- Anchor to applyMetafieldChangeapplyMetafieldChangeapplyMetafieldChange(change: MetafieldChange) => Promise<MetafieldChangeResult>(change: MetafieldChange) => Promise<MetafieldChangeResult>requiredrequired
Performs an update on a piece of metadata attached to the checkout. If successful, this mutation results in an update to the value retrieved through the
metafieldsproperty.
MetafieldChange
MetafieldRemoveChange | MetafieldUpdateChange | MetafieldRemoveCartChange | MetafieldUpdateCartChangeMetafieldRemoveChange
Removes a metafield.
- type
The type of the `MetafieldRemoveChange` API.
"removeMetafield" - key
The name of the metafield to remove.
string - namespace
The namespace of the metafield to remove.
string
MetafieldUpdateChange
Updates a metafield. If a metafield with the provided key and namespace does not already exist, it gets created.
- type
The type of the `MetafieldUpdateChange` API.
"updateMetafield" - key
The name of the metafield to update.
string - namespace
The namespace of the metafield to add.
string - value
The new information to store in the metafield.
string | number - valueType
The metafield’s information type.
"string" | "integer" | "json_string"
MetafieldRemoveCartChange
Removes a cart metafield.
- type
The type of the `MetafieldRemoveChange` API.
"removeCartMetafield" - key
The name of the metafield to remove.
string - namespace
The namespace of the metafield to remove.
string
MetafieldUpdateCartChange
Updates a cart metafield. If a metafield with the provided key and namespace does not already exist, it gets created.
- type
The type of the `MetafieldUpdateChange` API.
"updateCartMetafield" - metafield
{ key: string; namespace: string; value: string; type: string; }
MetafieldChangeResult
MetafieldChangeResultSuccess | MetafieldChangeResultErrorMetafieldChangeResultSuccess
- type
The type of the `MetafieldChangeResultSuccess` API.
"success"
MetafieldChangeResultError
- type
The type of the `MetafieldChangeResultError` API.
"error" - message
A message that explains the error. This message is useful for debugging. It is **not** localized, and therefore should not be presented directly to the buyer.
string
Anchor to useApplyMetafieldsChangeuse Apply Metafields Change()
Returns a function to mutate the metafields property of the checkout.
MetafieldChange
MetafieldRemoveChange | MetafieldUpdateChange | MetafieldRemoveCartChange | MetafieldUpdateCartChangeMetafieldRemoveChange
Removes a metafield.
- type
The type of the `MetafieldRemoveChange` API.
"removeMetafield" - key
The name of the metafield to remove.
string - namespace
The namespace of the metafield to remove.
string
MetafieldUpdateChange
Updates a metafield. If a metafield with the provided key and namespace does not already exist, it gets created.
- type
The type of the `MetafieldUpdateChange` API.
"updateMetafield" - key
The name of the metafield to update.
string - namespace
The namespace of the metafield to add.
string - value
The new information to store in the metafield.
string | number - valueType
The metafield’s information type.
"string" | "integer" | "json_string"
MetafieldRemoveCartChange
Removes a cart metafield.
- type
The type of the `MetafieldRemoveChange` API.
"removeCartMetafield" - key
The name of the metafield to remove.
string - namespace
The namespace of the metafield to remove.
string
MetafieldUpdateCartChange
Updates a cart metafield. If a metafield with the provided key and namespace does not already exist, it gets created.
- type
The type of the `MetafieldUpdateChange` API.
"updateCartMetafield" - metafield
{ key: string; namespace: string; value: string; type: string; }
MetafieldChangeResult
MetafieldChangeResultSuccess | MetafieldChangeResultErrorMetafieldChangeResultSuccess
- type
The type of the `MetafieldChangeResultSuccess` API.
"success"
MetafieldChangeResultError
- type
The type of the `MetafieldChangeResultError` API.
"error" - message
A message that explains the error. This message is useful for debugging. It is **not** localized, and therefore should not be presented directly to the buyer.
string