簡體   English   中英

如何在 shopify 中顯示名稱特定標簽

[英]How to show name specific tag in shopify

我想在我的 shopify 商店中顯示特定產品標簽的值。

產品標簽始終以Color_開頭,后跟顏色Color_Green

我只想顯示綠色。 (我可以對那部分使用 split 或 slice )

但我無法弄清楚只顯示以 Color_ 開頭的標簽,因為我的產品中添加了多個標簽。

這是我現在的代碼:

{%- for tag in product.tags -%} {%- assign tag_prefix = tag %} {%- if tag_prefix == "Color_" -%} {%- endif -%} {%- endfor -%}

試試這個片段

{% for tag in product.tags %}
    {% assign tag_prefix = tag %}
    {% if tag_prefix contains "Color_" %}
        {% assign tagValue = tag_prefix | replace: "Color_", "" %}
        {{ tagValue }}
    {% endif %}
{% endfor %}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM