我有一个shopify商店,我在shopify收藏页面添加了色样调色板。
如何仅显示库存中的颜色?
http://gloria22x.myshopify.com/collections/alle-produkte?sort_by=manual
谢谢,Alex
{% for option in product.options %}
{% if option == 'Color' %}
{% assign index = forloop.index0 %}
{% assign colorlist = '' %}
{% assign color = '' %}
{% for variant in product.variants %}
{% capture color %}
{{ variant.options[index] }}
{% endcapture %}
{% unless colorlist contains color %}
<img class="colorpalette" src="{{ color | downcase | strip_newlines | strip_html | replace:'ß','ss' | remove: ' ' | append: '.png' | asset_url }}" title="{{ color | camelize }}" alt="{{ color | camelize }}" width="16" height="16"/>
{% capture tempList %}
{{colorlist | append: color | append: ‘ ‘}}
{% endcapture %}
{% assign colorlist = tempList %}
{% endunless %}
{% endfor %}
{% endif %}
{% endfor %}
答案 0 :(得分:0)
您需要检查每个变体的inventory_quantity
。试试这个:
...
{% for variant in product.variants %}
{% if variant.inventory_quantity > 0 %}
...
{% endif %}
{% endfor %}
...