簡體   English   中英

我Shopify的收藏頁上的色板

[英]Color swatch on collections page I 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 %} 

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

...
{% for variant in product.variants %}
    {% if variant.inventory_quantity > 0 %}
        ...
    {% endif %}
{% endfor %}
...

暫無
暫無

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

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