2014-10-21 70 views
0

我有一個shopify商店,我添加了一個色板調色板到我的shopify集合頁面。集合頁面上的色樣我Shopify

如何只顯示有庫存的顏色?

http://gloria22x.myshopify.com/collections/alle-produkte?sort_by=manual

謝謝,亞歷克斯

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

您需要檢查inventory_quantity對每個變種。試試這個:

... 
{% for variant in product.variants %} 
    {% if variant.inventory_quantity > 0 %} 
     ... 
    {% endif %} 
{% endfor %} 
... 
相關問題