shopify - 集合页面中的尺寸变体
问题描述
这是我们的网站: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>
解决方案
有一个名为的属性,product.has_only_default_variant
您可以使用它来确定产品是否具有与默认变体不同的变体。
我会用{% unless product.has_only_default_variant %}
"your code here"
{% endunless %}
推荐阅读
- html - 选择选项不显示在 html 中
- kubernetes - 使用 terraform kubernetes 提供程序创建命名空间时出错
- python - 从 json 中取出键和值来分隔 pandas 中的行
- android-studio - 我使用 500 多张图片,文件夹太大。我怎样才能减少
- python - 字符串 pandas 中的正则表达式(拆分)
- r - 过滤多个分类数据
- ios - 将 Postman GET curl 转换为 swift url 会话请求
- c++ - 在 C++ 中创建单例类的实例
- flutter - 如何在flutter中将https网络URL图像下载到应用程序目录中
- excel - 如何使用 .List 函数填充列表框?