Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more
Hello. I had a problem that a lot of people seemed to had, and, as I wasn't able to find the answer I fixed it myself and I am sharing the answer.
I had pagination enabled, plus I wanted to hide the unavailable products. It is done like so.
In the collection-template.liquid, change:
{% paginate collection.products by 20 %}
For
{% paginate collection.products | where: "available", true by 20 %}
Then, locate the loop:
{% for product in collection.products %}
{% assign featured = product %}
<div class="grid__item {{grid_item_width}}">
{% include 'product-grid-item' %}
</div>
...
And replace it for:
{% for product in collection.products %}
{% if product.available == true %}
{% assign featured = product %}
<div class="grid__item {{grid_item_width}}">
{% include 'product-grid-item' %}
</div>
{% endif %}...
Thank you for posting this, sir. Unfortunately it did not work for me.
This does not work for me
{% paginate blogs['recipe-database'].articles | where 'tags','Chocolate' by 50 %}
{% for article in blog.articles %}
<h2>{{article.title}}</h2>
{% endfor %}
{% endpaginate %}
What behavior did you observe from this? Did the pagination display the normal number of pages and hide the products that did not meet the criteria?