【发布时间】:2017-12-22 23:22:28
【问题描述】:
我正在尝试在我的收藏页面中设置过滤器。
到目前为止,我设法设置了一个很棒的自定义标签过滤器,如下所示:
<div class="collection-sort">
{% assign tags = 'Black, Slate, Military Green' | replace: ' ,', ',' | replace: ', ', ',' | split: ',' %}
<select id="FilterBy" class="collection-sort__input">
<option value="/collections/{{ collection.handle }}">Choose Color</option>
{% for tag in tags %}
{% if current_tags contains tag %}
<option value="/collections/{{ collection.handle }}/{{tag}} " selected>{{ tag }}</option>
{% elsif collection.all_tags contains tag %}
<option value="/collections/{{ collection.handle }}/{{tag}}">{{ tag }}</option>
{% endif %}
{% endfor %}
</select>
</div>
但是,我希望有一个动态大小过滤器(使用 Variant)
为此,我尝试了以下方法:
<div class="collection-sort">
<span value="">Choose Size</span>
{% for variant in collection.variants %}
{% if variant.available %}
<span value="{{ variant.id }}" >{{ variant.size}}</span>
{% else %}
<span value="{{ variant.id }}" >{{ variant.size }}</span>
{% endif %}
{% endfor %}
</div>
但我的下拉列表中没有出现任何内容。 . .我所有的产品都输入了尺寸作为产品选项/变体。 . .
有人设法完成这项工作吗?这将非常有帮助!
非常感谢
【问题讨论】:
标签: collections filter shopify product variant