[英]How do I display the variant image when the color swatch of a variant is hovered on 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.