首页 > 解决方案 > 集合页面中的尺寸变体

问题描述

这是我们的网站:https ://bohemianvibes.com.au/

我们的主要问题是集合页面中的尺寸变体。例如,这个系列 - https://bohemianvibes.com.au/collections/all-quilt-cover-sets

您将在每个产品下方看到尺寸变体。但是,对于没有尺寸变体的物品,例如此系列https://bohemianvibes.com.au/collections/round-beach-towels

您将在产品下方看到默认标题。我们怎样才能删除它?

我们希望在集合页面中的每个产品下方显示尺寸变体,不包括那些没有尺寸变体的商品。

我希望你能指导我完成这些步骤以及我应该在哪里输入代码。

目前,我只接触了 PRODUCT-GRID-ITEM.LIQUID。下面是代码:

{% for option in product.options %}
{% if option == 'Size' %}  **I changed this 'Size' to something else I want**
{% assign index = forloop.index0 %}
{% assign colorlist = '' %}
{% assign color = '' %}
{% for variant in product.variants %}
{% capture color %}
{{ variant.options[index] }}
{% endcapture %}

{% unless colorlist contains color %}
  {% if variant.available %}

  <li id="{{ variant.id }}" title="{{ variant.inventory_quantity }} In Stock" class="avactive"><a href="{{ product.url | within: collection }}?variant={{ variant.id }}">{{ color | downcase }}</a></li>

  {% else %}

  <li id="{{ variant.id }}" title="Out of Stock"  class="notactve" >{{ color | downcase }}</li>

  {% endif %}

{% capture tempList %}
{{colorlist | append: color | append: " " }}
{% endcapture %}
{% assign colorlist = tempList %}
{% endunless %}
{% endfor %}
{% endif %}
{% endfor %}
</ul>

标签: shopify

解决方案


有一个名为的属性,product.has_only_default_variant 您可以使用它来确定产品是否具有与默认变体不同的变体。

我会用{% unless product.has_only_default_variant %} "your code here" {% endunless %}


推荐阅读