githubEdit

Metafield representation object

triangle-exclamation
circle-info

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 objectarrow-up-right, 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.

circle-exclamation

What it contains

A metafield representation object always contains these three properties:

Resource references

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.

How to access it

A metafield representation object can only be retrieved via metafield collection lookup: resource.metafields.namespace.key.

Last updated

Was this helpful?