如何解决Shopify:动态链接以隐藏库存
我的shopify网站中有以下代码,当前所做的只是显示指向“有货”或“显示全部”的链接。我想使链接更具动态性,因此,如果某人按某种产品进行过滤,然后单击“有货”链接,则该链接将仅显示该产品的有货。 例如。如果点击链接后它们位于/ collections / all / Product1,则应转到/ collections / in-stock / Product1
我当前的代码:
<div class="filter-stock">
{% if page_title contains "Products" %}
<a href="/collections/in-stock"><b>Hide 'Sold Out' items</b></a>
{% endif %}
{% if page_title contains "IN STOCK" %}
<a href="/collections/all"><b>Show All Products</b></a>
{% endif %}
似乎有效的新代码:
<div class="filter-stock">
{% if current_tags %}
{% for tag in current_tags %}
{% if collection == blank or collection.handle != 'in-stock' %}
<a href="/collections/in-stock/{{ tag | handleize }}"><b>Hide 'Sold Out' items</b></a>
{% endif %}
{% if collection and collection.handle == 'in-stock' %}
<a href="/collections/all/{{ tag | handleize }}"><b>Show All Products</b></a>
{% endif %}
{% endfor %}
{% else %}
{% if collection == blank or collection.handle != 'in-stock' %}
<a href="/collections/in-stock"><b>Hide 'Sold Out' items</b></a>
{% endif %}
{% if collection and collection.handle == 'in-stock' %}
<a href="/collections/all"><b>Show All Products</b></a>
{% endif %}
{% endif %}
</div>
解决方法
我希望它设置如下内容:
<div class="filter-stock">
{% if collection == blank or collection.handle != 'in-stock' %}
<a href="/collections/in-stock{% if product %}/{{ product.handle }}{% endif %}"><b>Hide 'Sold Out' items</b></a>
{% endif %}
{% if collection and collection.handle == 'in-stock' %}
<a href="/collections/all{% if product %}/{{ product.handle }}{% endif %}"><b>Show All Products</b></a>
{% endif %}
</div>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。