Metafield object
Last updated
Was this helpful?
Last updated
Was this helpful?
Important Notice
Shopify is deprecating the Shopify Admin REST API which the Mechanic REST objects depend on. The first round of deprecations involve the product and variant endpoints. Read about the deprecation and . Use the going forward. The and objects will cease to work on on Feb 1, 2025 due to the changes being made by Shopify. Shopify will phase out the REST API completely over time, you can read more about this .
All of our will be ported to use GraphQL only, which will provide a model for how you can update your custom tasks. You'll be able to update your non-customized library tasks with a click of a button Please see these for migrating your custom tasks to GraphQL.
The metafield object reflects the REST Admin API's representation of a metafield.
Mechanic includes support for the metafield object for completeness, but it is not the most useful way to go about using metafield values (see ).
Every property from
For many metafield types (e.g. dimension, weight, decimal, etc), the value
attribute of the metafield object is a JSON-encoded string. For most scalar types (e.g. boolean, number_integer), the value
attribute has a matching type.
The simplest way to access a usable version of a metafield value is via the , i.e. resource.metafields.namespace.key.value
.
For modern metafields, use resource.metafields.namespace.key.metafield
to retrieve the metafield object itself.
Use resource.metafields.namespace.key
to access the for that metafield.
For deprecated metafields, use resource.metafields.namespace.key
to retrieve the parsed, appropriately-typed metafield value.