metafield_ text
Generates a text version of the data from a metafield object.
The filter doesn't currently support list metafields other than and .
The filter doesn't currently support list metafields other than and .
Note: The <code><span class="PreventFireFoxApplyingGapToWBR">metafield<wbr/>_text</span></code> filter doesn't currently support list metafields other than <code><span class="PreventFireFoxApplyingGapToWBR">list.single<wbr/>_line<wbr/>_text<wbr/>_field</span></code> and <code><span class="PreventFireFoxApplyingGapToWBR">list.metaobject<wbr/>_reference</span></code>.
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. |
Code
{{ product.metafields.information.dosage | metafield_text }}Data
{
"product": {
"metafields": {}
}
}Output
Output
Potion dosagesComplex types
list.metaobject_reference
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 .
Code
{{ product.metafields.information.ingredients | metafield_text: field: 'name' }}Data
{
"product": {
"metafields": {}
}
}Output
Output
Spinach, Kale, and Mushroomsmetaobject_reference
Outputs the metafield text for the metaobject field specified by the required field parameter. The field parameter can reference only metafields of type .
Code
{{ product.metafields.information.primary_ingredient | metafield_tag: field: 'name' }}Data
{
"product": {
"metafields": {}
}
}Output
Output
<span class="metafield-single_line_text_field">Spinach</span>