metafield

A metafield attached to a parent object.

To learn about how to access a metafield on a specific object, refer to Access metafields.

PropertiesDescription
valueThe value of the metafield.

The following table outlines the value format for each metafield type:

TypeReturned format
single_line_text_field

multi_line_text_field
A string
product_referenceA product object
collection_referenceA collection object
file_referenceA image object
number_integer

number_decimal
A number
date

date_time
A date string
url_referenceA URL string
jsonA JSON object
booleanA boolean
colorA color string
weight

volume

dimension
A measurement object
ratingA rating object

Access metafields

The access path for metafields consists of two layers:

  • namespace - A grouping of metafields to prevent conflicts.
  • key - The metafield name.

Given this, you can access the metafield object with the following syntax:

{{ resource.metafields.namespace.key }}
{{ product.metafields.custom.directions.value }}
Take with a meal

Accessing metafields of type

The value property of metafields of type json returns a JSON object. You can access the properties of this object directly in Liquid, either by name or 0-based index. You can also iterate through the properties.

Temperature: {{ product.metafields.custom.burn_temperature.value.temperature }}

Unit: {{ product.metafields.custom.burn_temperature.value['unit'] }}

{% for property in product.metafields.custom.burn_temperature.value %}
  {{ property[0] | capitalize }}: {{ property[1] }}
{% endfor %}
Temperature: 700

Unit: degrees

Temperature: 700
Unit: degrees
Scale: Fahrenheit