I have a collection with 98 products. I have my theme set to show 7 rows and 4 items per row on each page so pagination is by 28’s.
I want to only show available products on each page and paginate the pages evenly. I also want to show the total available products at the top of the page.
Right now:
page1 (1-28) shows 18 products.
page2 (29-56) shows 16 products.
page3 (57-84) shows 10 products.
page4 (85-98) shows 3 products.
I tried to follow the recommendation in a similar thread:
by setting {% paginate collection.products | where: “available”, true by paginate_by %} instead of {% paginate collection.products by paginate_by %}
but instead of paginating the available products evenly by 28’s it paginated all products by 20’s and ignored “by paginate_by” completely.
To get the total available products I also tried the recommendation in this thread:
{% assign availableItems = 0 %}
{% for product in collection.products %}
{% assign itemavail = product %}
{% if itemavail.available %}
{% assign availableItems = availableItems | plus: 1 %}
{% endif %}
{% endfor %}
{{ availableItems }} //Output
but I got 32 as output, expected total = 18 + 16 + 10 + 3 = 47
and I noticed that if I remove the {% if itemavail.available %} condition I get 50
so I cannot get the total available product count in my collection.
I pasted screenshots of each page below. My collection page is at https://craftshack.com/collections/repeal-day-expo-2020




