Variant and Availability filter not working

Topic summary

A Shopify store owner encountered an issue where filtering products by size variants displayed items that were out of stock for those specific sizes, even when using the “In Stock” availability filter.

Initial Problem:

  • Size filters showed products with sold-out variants
  • Using Shopify Search & Discovery app with tag-based filtering
  • Manually removing variants after sales was impractical

Root Cause Identified:

  • Tag-based filtering (e.g., filter.p.tag=L) was causing the issue
  • Tags like “L” matched products with “XXL” variants, showing results even when the specific “L” size was unavailable

Solution Provided:

  • Switch from tag-based filters to Product Option filters in Search & Discovery
  • Implement code in product-variant-options.liquid to hide disabled/out-of-stock variants:
{% if option_disabled %}{% continue %}{% endif %}

Outcome:
The solution successfully resolved the filtering issue, ensuring only products with available variants in the selected size are displayed.

Summarized with AI on November 14. AI used: claude-sonnet-4-5-20250929.

Good afternoon everyone :blush: . I have a filter by sizes which are as variants and when filtering it brings me the products that I do not have in stock. I would be very grateful if someone could give me a recommendation to be able to use the filters correctly. Thank you very much to all!

site: www.kalascouture.com

Hi @Kalascouture I have gone through your site and got your issue.

If the product is soldout and you are not taking preorder for that product then you should draft that product so that no customer will be able to see the product. Because even if customer is right now viewing that product but they are unable to order it or take any action, in this way you will be loosing potential customer who should have bought some other product if the sold out product will not be their.

So in this case you just simply Draft all the product which are soldout and not available for preorder and your filter will be working perfectly fine.

If you need any assistance then please feel free to ask the same.

Hopefully it will help you. If yes then Please hit Like and Mark it as solution!

Best Regards

Sahil

Hi @Kalascouture How about use “Shopify Search & Discovery” from Shopify ? There you can setup filter by product option, eq: Size variant.

Hopefully it will help you. If yes then Please hit Like and Mark it as solution!

The product may not be completely soldout, there might be only some variant
that are sold out.. It will be highly manual removal each variant after a
sale. Please help

I already uses search and discovery for my shop filters.

example:

When user selects filter size as S and available as is available.. page should not show this product.. but it shows.. thats what i am trying to resolve

Ahh I see, First I need to tell you that in Search and discovery, dont use Tag as filter for the “Size” but use Product Option and in URL you will see

enzoyuna2023_0-1700181252072.png

Instead /collections/new-arrivals?sort_by=best-selling&filter.p.tag=L&filter.v.availability=1

Because I can see when using Tag that if the filter is “In Stock” we still have “L” in the filter options but the result “L” is out of stock. This is because XXL results in L taken from XXL. In Dawn theme let’s hide variant when “out of stock”.
Write this code in product-variant-options.liquid

{% if option_disabled %} {% continue %} {% endif %}

With this trick your filter result will more relevant.

Hope this can help you.

1 Like

Wow.. this worked :blush: :blush: thank you so much..