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.
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:
Log in to Shopify Admin, go to Online Store > Themes.
Click Actions > Edit code on the Dawn theme.
In the Sections folder, find collection-template.liquid.
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.