Paginate not accounting for reduced collection size

Highlighted
Shopify Partner
15 0 6

I'm looking to do something simple: only show products that are in stock on the store.

 

Here's the consequential pieces of my collection-template.liquid file:

 

{% if section.settings.layout == 'grid' %}
  {%- assign limit = section.settings.grid | times: section.settings.rows -%}
{% else %}
  {%- assign limit = 16 -%}
{% endif %}

{% assign products = collection.products | where: "available" %}

{% paginate products by limit %} {% for product in products %} <li class="grid__item grid__item--{{section.id}} {{ grid_item_width }}"> {% include 'product-card-grid', max_height: max_height %} </li>

 

 

The out of stock products are no longer being displayed on the store: https://shane-dev-shop.myshopify.com/collections/all - but the pagination is still being rendered as if the collection has not been filtered using `where` .

 

The collection has 9 products, only 2 of which are in stock and the `limit` = 8 with the current store settings.

 

Am I missing something here?

0 Likes
Highlighted
Shopify Partner
15 0 6
Highlighted
Shopify Partner
15 0 6

Hi, can someone help me out here? I'm still unable to find a solution.

 

What I'm trying to do is filter out products that are unavailable from appearing on the shop. The `where` filter works great for this, though it breaks the pagination as you can see if you visit the store: https://shane-dev-shop.myshopify.com/collections/all

 

{% assign products = collection.products | where: "available" %}

{% paginate products by limit %}

 

0 Likes
Highlighted
Shopify Partner
15 0 6

Any chance someone knows what's going on?

0 Likes
Highlighted
Shopify Partner
5 0 0

I faced the same error. Frankly from my experience, Shopify would just ignore our questions or provide non-solution....

0 Likes