如何仅在字段已填充时显示元字段属性,否则隐藏它?

发布于 2025-01-12 21:39:05 字数 456 浏览 3 评论 0原文

仅当字段已填充时,此代码片段才应显示元字段。

{%- 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>

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>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

眼泪也成诗 2025-01-19 21:39:05
{%- if product.metafields.meta_field.meta_field != blank -%}
     {{ product.metafields.meta_field.meta_field }}
{%- endif -%}

{%- if product.metafields.meta_field.meta_field != blank -%}
     {{ product.metafields.meta_field.meta_field }}
{%- endif -%}

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文