metafield_ text
metafield | metafield_text
returns string
Generates a text version of the metafield data.
Note
The filter doesn't currently support list metafields other than
and
.
Anchor to Basic types
Basic types
The following outlines the output for each metafield type:
Metafield type | Output |
---|---|
| The metafield text. |
| The metafield text. |
| The page title. |
| The product title. |
| The collection title. |
| The variant title. |
| The file URL. |
| The number. |
| The number. |
date | The date. |
date-time | The date and time. |
url | The URL. |
json | The JSON. |
boolean | The boolean value. |
color | The color value. |
weight | The weight value and unit. If the value is a decimal with more than two places, then it'll be formatted to have a precision of two with trailing zeros removed. |
volume | The volume value and unit. If the value is a decimal with more than two places, then it'll be formatted to have a precision of two with trailing zeros removed. |
dimension | The dimension value and unit. If the value is a decimal with more than two places, then it'll be formatted to have a precision of two with trailing zeros removed. |
rating | The rating value. |
| The metafield values in sentence format. For example, if you had the values Toronto , Ottawa , and Vancouver , then the output would be:Toronto, Ottawa, and Vancouver |
money | The money value, formatted using the store's HTML with currency setting. |
| The rich text value as simple text. |
{{ product.metafields.information.dosage | metafield_text }}
{{ product.metafields.information.dosage | metafield_text }}
{
"product": {
"metafields": {}
}
}
Output
Potion dosages
Anchor to Complex types
Complex types
Anchor to list.metaobject_reference
list.metaobject_reference
metafield | metafield_text: field: string
Outputs the list of metaobjects in sentence format. The required field
parameter specifies which field should be rendered for each metaobject. The field
parameter can reference only metafields of type .
{{ product.metafields.information.ingredients | metafield_text: field: 'name' }}
{{ product.metafields.information.ingredients | metafield_text: field: 'name' }}
{
"product": {
"metafields": {}
}
}
Output
Spinach, Kale, and Mushrooms
Anchor to metaobject_reference
metaobject_reference
metafield | metafield_text: field: string
Outputs the metafield text for the metaobject field specified by the required field
parameter. The field
parameter can reference only metafields of type .
{{ product.metafields.information.primary_ingredient | metafield_tag: field: 'name' }}
{{ product.metafields.information.primary_ingredient | metafield_tag: field: 'name' }}
{
"product": {
"metafields": {}
}
}
Output
<span class="metafield-single_line_text_field">Spinach</span>
Was this page helpful?