Disable product from showing up in outofstock if any of its variant is in stock.

Hi, I am using default dawn theme and my products are showing up in Out of stock section of the availablity filter in collection page, even if some of its variants are in stock. i want them to only show up in out of stock if all their variants are out of stock.

this product with its variants in stock is showing up in the out of stock section

is this possible?

Hi @sachnr ,

To modify the availability filter in the Dawn theme so that products only show as “Out of Stock” if all variants are out of stock, follow these steps:

  1. Log in to Shopify Admin, go to Online Store > Themes.

  2. Click Actions > Edit code on the Dawn theme.

  3. In the Sections folder, find collection-template.liquid.

  4. Locate the code that checks variant availability and modify it to:

{% assign all_out_of_stock = true %}
{% for variant in product.variants %}
    {% if variant.available %}
        {% assign all_out_of_stock = false %}
    {% endif %}
{% endfor %}

{% if all_out_of_stock %}
    
{% else %}
    
{% endif %}

save the changes and preview.

Got it! If you found my suggestions helpful, please consider liking or marking it as a solution.
Your feedback is appreciated! If you have any more questions or need further assistance, just let me know.

Thanks & Regards
Akshay Bhatt

There is no file named collection-template.liquid in the current dawn theme.
my theme version is 15.2.0

Hi @sachnr ,

in the section folder open main-collection.liquid

then find the loop displaying product starts with {% for productin collection.products%}

then add the above logic already shared with you .