Filter is Showing Out Of Stock Variant - DAWN Theme

Filter is Showing Out Of Stock Variant - DAWN Theme

Carina13
Excursionist
19 1 1

 

Hi all 🙂

 

we sell shoes with different variants (sizes).

 

When I filter by size the result list unfortunately shows me also products with no inventory of the choosen size. This is very disappointing for my customers.

 

Have anyone a solution for me to hide the variants out of stock by using the filter function?

 

We use the DAWN theme. The shop is: https://onlineshop.sisento.de

 

Thank you!

Karin

 

Replies 4 (4)

NomtechSolution
Astronaut
1245 113 155
  1. Find the filter code: In the theme code editor, navigate to the file that handles the filtering functionality. This might vary depending on how the theme is structured, but typically you would look for a file named something like collection-template.liquid or collection.liquid.

  2. Locate the filter section: Within the file, find the section of code that handles the filtering of variants based on size. Look for code that involves a loop over the available variants and some conditions for filtering.

  3. Modify the filter conditions: In the filtering loop, you need to add an additional condition to exclude variants that are out of stock. The exact code modification will depend on how the filtering is implemented in your theme, but here's an example of what it might look like:

 

{% for variant in collection.all_variants %}
  {% if variant.available and variant.inventory_quantity > 0 %}
    <!-- Code to display the variant -->
  {% endif %}
{% endfor %}

 

Carina13
Excursionist
19 1 1

Thanks, but unfortunately this answer is not specific enough. I could not find any of these liquids in my theme. In which Liquid can I find this specifically in the DAWN Theme? 

And where is the part of code exactly in this liquid where I need to input your code? I am not fit in liquid and coding so I would need more help. Thanks

HobAdams
Shopify Partner
2 0 1

Won’t this just stop the product rendering but the pagination / product count etc would still be wrong.

 

I think the filtering needs to happen higher than template level.

minhcu
Shopify Partner
61 0 3

you can try using this filter app https://apps.shopify.com/ultimate-search-and-filter-1

it have a setting called Hide unavailable variant when filter is selected, which should meet your need.

Don't stop grinding