Shopify Liquid code examples
Product metafields store and display additional product information that doesn't otherwise exist in the Shopify Admin. This example demonstrates how to add washing instructions to your products and display them on the product page. See more examples of how to use product metafields in the Shopify Help Center.
- Install a Metafields app from the Shopfiy App Store.
- Create a new metafield. For the namespace, enter
instructions
, for the key enterwash
, and for the value enterCold water
. - Create another metafield. For the namespace enter
instructions
, for the key enterdry
and for the value enterTumble dry
. - Add the following code to either your
product.liquid
template file, or aproduct-template.liquid
section file.
{%- if product.metafields.instructions != blank -%}
<ul>
{%- for field in product.metafields.instructions -%}
<li>{{ field | first }}: {{ field | last }}</li>
{%- endfor -%}
</ul>
{%- endif -%}
Please note: We have intentionally limited CSS and JavaScript, and removed translation strings in order to keep these examples compatible with any theme. Any CSS we have included is for accessibility or rendering purposes.