Size Filter not working

hi,

Size filter is not working on collection page, however it reflects fine on pdp.

‘S’ shows on collection page:

‘S’ size is sold out on PDP:

I am using search and discovery for filters, do not wish to change it as this is best which I could find in free app.

using ella theme, can you please help which code shall I fix.

Thanks,
Khyati

Hello I checked your store and i can’t seem to find anything that is wrong with it. So what do you want to be done on the store

@RivaajEthnic
I think it shows correctly on collection page. As a customer if I checked small box with filter for size so it shows this product because it is in small size but their stock is not available but If I land to the PDP page then it is showing that small size is not available that I wanted to purchase. So it is working correctly.

The app you are using for filter please check its setting that if they have option to check the stock availability on collection page too then I think it should work fine for you.

Hi @RivaajEthnic,

I tested and it works fine.
Currently, Shopify is working filter with default OR logic, so when you select 2 sizes, it will show all products including 1 of 2 sizes.


I hope it is clear to you.
If I helped you, then a Like would be truly appreciated.

This is an issue with the discovery and search app, when using variants and one of these variants is available, the size filter always remains visible even if the item is out of stock, and the same will happen with other filters. You can resolve this by creating an availability filter in the admin of the Search and Discovery app and always setting it to 1, so that the user always sees products that are available.

Steps:

  1. Enter the Search and Discovery app, create a new filter associated with availability.
  2. Then enter a collection and apply the availability filter.
  3. If this solution seems appropriate to you, let me know and I can share a script (JavaScript) that applies availability always as 1 (example: /collections/automated-collection?filter.v.availability=1). This is the solution I found for some clients and I believe it can work for you as well, but please test it first.

Hi,

Hope this will help

  • At snippets/filter-logic.liquid (or something similar used for filter rendering). only include sizes that have at least 1 in-stock variant.

Code example

{% assign available_sizes = '' %}

{% for product in collection.products %}
  {% for variant in product.variants %}
    {% if variant.available %}
      {% assign size = variant.options[0] %}
      {% unless available_sizes contains size %}
        {% assign available_sizes = available_sizes | append: size | append: ',' %}
      {% endunless %}
    {% endif %}
  {% endfor %}
{% endfor %}

{% assign size_list = available_sizes | split: ',' %}

<ul>
  {% for size in size_list %}
    {% unless size == '' %}
      <li>{{ size }}</li>
    {% endunless %}
  {% endfor %}
</ul>

Hi Joseamaya,

Thank you for your revert.

Applying the availability filter in search and discovery doesnt show availability via product size. it shows only ‘in stock’ and ‘out of stock’. I was looking for a fix where in this is incorporated directly in the size filter . do you think it is possible?

Thanks,

Khyati

Oh! I think I didn’t make myself clear: when you apply the availability filter to “Only available,” the sizes that aren’t available will automatically be removed from the existing size filter. I use this because otherwise you’d have to edit the theme code to get the desired logic, which often solves the problem.