Shopify在集合中显示颜色变体,但不显示大小变体
目标是在Shopify的收藏页面上显示额外的颜色变体。 使用供应主题。我正在显示集合中的所有变体图像,但如果存在变体,我只想显示颜色变体。有些项目没有变体,有些项目有大小变体。有些有颜色,有些有大小和颜色。我不想在“收藏”页面上显示颜色的所有尺寸变体。 收集液体Shopify在集合中显示颜色变体,但不显示大小变体,shopify,liquid,Shopify,Liquid,目标是在Shopify的收藏页面上显示额外的颜色变体。 使用供应主题。我正在显示集合中的所有变体图像,但如果存在变体,我只想显示颜色变体。有些项目没有变体,有些项目有大小变体。有些有颜色,有些有大小和颜色。我不想在“收藏”页面上显示颜色的所有尺寸变体。 收集液体 {%用于集合中的产品。产品%} {product.variants%中的变量为%0} {%if有_侧边栏%} {%assign grid_item_width='大--四分之一中--三分之一小--一半'%} {%else%} {%as
{%用于集合中的产品。产品%}
{product.variants%中的变量为%0}
{%if有_侧边栏%}
{%assign grid_item_width='大--四分之一中--三分之一小--一半'%}
{%else%}
{%assign grid_item_width='大--五分之一中--三分之一小--一半'%}
{%endif%}
{%include'产品网格项“%”
{%else%}
{{'collections.general.no|u匹配'|t}
{%endfor%}
{%endfor%}
product-grid-item.liquid
<div class="grid-item {{ grid_item_width }}{% if sold_out %} sold-out{% endif %}{% if on_sale %} on-sale{% endif %}">
{%如果售罄%}
{{'products.product.salled|t}
{%endif%}
我想我需要先用if语句检查变量,然后为颜色添加forloop。
{product.options%中的选项为%s}
{%if选项=='颜色'%}
任何帮助都将不胜感激 像这样的事情应该会让你开始 首先我们循环产品选项,然后我们说我们只想要颜色或颜色,然后我们循环所有属于该选项的变体。。。抓取颜色并创建一个带有标题的列表项
<ul>
{% for option in product.options %}
{% if option == "Color" or option == "Colour" %}
{% assign index = forloop.index0 %}
{% assign colorlist = '' %}
{% assign color = '' %}
{% for variant in product.variants %}
{% capture color %}
{{ variant.options[index] }}
{% endcapture %}
{% unless colorlist contains color %}
<li><span class="color-{{color | handle }}"><a href="{{variant.id}}">{{color}}</a></span></li>
{% capture tempList %}
{{colorlist | append: color | append: ' '}}
{% endcapture %}
{% assign colorlist = tempList %}
{% endunless %}
{% endfor %}
{% endif %}
{% endfor %}
</ul>
{product.options%中的选项为%s}
{%if option==“Color”或option==“Color”%}
{%assign index=forloop.index0%}
{%assign colorlist=''%}
{%assign color=''%}
{product.variants%中的变量为%0}
{%capture color%}
{{variant.options[index]}
{%endcapture%}
{%除非颜色列表包含颜色%}
{%capture templast%}
{{colorlist | append:color | append:''}
{%endcapture%}
{%assign colorlist=templast%}
{%end除非%}
{%endfor%}
{%endif%}
{%endfor%}
像这样的事情应该会让你开始
首先我们循环产品选项,然后我们说我们只想要颜色或颜色,然后我们循环所有属于该选项的变体。。。抓取颜色并创建一个带有标题的列表项
<ul>
{% for option in product.options %}
{% if option == "Color" or option == "Colour" %}
{% assign index = forloop.index0 %}
{% assign colorlist = '' %}
{% assign color = '' %}
{% for variant in product.variants %}
{% capture color %}
{{ variant.options[index] }}
{% endcapture %}
{% unless colorlist contains color %}
<li><span class="color-{{color | handle }}"><a href="{{variant.id}}">{{color}}</a></span></li>
{% capture tempList %}
{{colorlist | append: color | append: ' '}}
{% endcapture %}
{% assign colorlist = tempList %}
{% endunless %}
{% endfor %}
{% endif %}
{% endfor %}
</ul>
{product.options%中的选项为%s}
{%if option==“Color”或option==“Color”%}
{%assign index=forloop.index0%}
{%assign colorlist=''%}
{%assign color=''%}
{product.variants%中的变量为%0}
{%capture color%}
{{variant.options[index]}
{%endcapture%}
{%除非颜色列表包含颜色%}
{%capture templast%}
{{colorlist | append:color | append:''}
{%endcapture%}
{%assign colorlist=templast%}
{%end除非%}
{%endfor%}
{%endif%}
{%endfor%}