Metafield representation object
Last updated
Last updated
Important Updates
π£ Shopify REST DeprecationImportant 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 here and here. Use the GraphQL going forward. The product and variant 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 here.
All of our library tasks 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 guides for migrating your custom tasks to GraphQL.
This page is part of a series: see Metafields for an overview on how Mechanic's Liquid implementation thinks about metafields.
Mechanic's metafield representation object mirrors Shopify's metafield Liquid object, in that it makes the metafield type and value easily available, in a usable form. It is not the same as Mechanic's metafield object, which contains the REST Admin API representation of a metafield.
Metafield representation objects are only available for modern metafield types. They are not available for deprecated metafields (i.e. json_string, number, and string).
A metafield representation object always contains these three properties:
type
β the type of the metafield (see Shopify's reference list)
value
β the parsed, appropriately-typed value of the metafield
metafield
β the source metafield object, useful for retrieving the metafield ID
For reference types that map to a REST API resource (e.g. page_reference, product_reference, and variant_reference), a metafield representation object also contains a property named after the resource in question.
For example, a product_reference metafield representation object contains a product
property, which holds the associated product object. This means that the referenced product may be retrieved using resource.metafields.namespace.key.product
.
A metafield representation object can only be retrieved via metafield collection lookup: resource.metafields.namespace.key
.