Truly fine
Documentation.
Building metafield and metaobject paths
Last update:
The product’s Details block, allows you to display a list of product-level or variant-level metafields and metaobjects. In order to be able to reference specific fields, you need to provide a label and path for each field that you want to display. This guide explains how you can construct the path that you need to provide.
Metafield namespace and key
In general, metafields can be referenced by their namespace and key. By default, the namespace is custom and the key is a normalized version of the field’s name (e.g. “Rim size” becomes rim_size). Shopify displays these as “paths” delimited by a dot, i.e. custom.rim_size
Both of them can be customized, but only at the time that you create the metafield. Once you create it, they cannot be changed. For example, you could change the namespace to my_fields and the key to rim_diameter, in which case the path would be my_fields.rim_diameter
From now on, we will refer to these as namespace.key which you need to change with the specifics of your field.
Product-level metafields
In order to display your product-level metafield, the namespace and key are enough to reference the field.
namespace.key
Variant-level metafields
Variant-level metafields also have a namespace and a key, however the field’s value can be different on each variant. If you want to display a variant metafield (that is, the currently selected variant), you need to prefix the path with “variant.“:
variant.namespace.key
Metaobjects
Assuming you already have a metaobject definition and a few entries, you can associate a product or a variant with a specific metaobject entry by creating a metafield of the Metaobject type. This metafield can be referenced by its namespace.key as any other metafield. In order to access the metaoject’s fields however, you need to append a “>” sign and the field’s name at the end.
namespace.key>field
variant.namespace.key>field
List fields
List fields, that is metafield or metaobject fields that accept more than one value, are supported automatically. However, they are only supported at the end of the path.
namespace.list_key
variant.namespace.list_key
namespace.key>list_field
variant.namespace.key>list_field
List fields cannot be anywhere in between. E.g. these are not allowed:
namespace.list_key>field
variant.namespace.list_key>field
Reference fields
In general, you need the “>” character in order to access the fields and values of a reference field or object, and the “.” character to access non-reference fields and values. Using these two, allows you to construct and display information that may require more complex paths. E.g.:
variant.custom.metaobject_1>metaobject_2>metaobject_2_list_field
While this is doable, we strongly advise that you keep your metafields structure as straightforward as possible!
Can't find what you are looking for? Feel free to submit a request.