'How do I display a metafield property only if the field is filled, else hide it?
This code snippet should display the metafield only if the field is filled.
{%- if line_item.properties != empty -%}
<ul class="CartItem__PropertyList">
{%- for property in line_item.properties -%}
{%- assign first_character_in_key = property.first | truncate: 1, '' -%}
{%- if property.last == blank or first_character_in_key == '_' -%}
{%- continue -%}
{%- endif -%}
<p class="CartItem__Variant">Ringgröße: {{ property.last }}</p>
{%- endfor -%}
</ul>
Solution 1:[1]
{%- if product.metafields.meta_field.meta_field != blank -%}
{{ product.metafields.meta_field.meta_field }}
{%- endif -%}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | chirag khunt |
