Shopify themes, liquid, logos, and UX
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
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
.
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.
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 %}
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
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.
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.
Learn how to expand your operations internationally with Shopify Academy’s learning path...
By Shopify Feb 4, 2025Hey Community, happy February! Looking back to January, we kicked off the year with 8....
By JasonH Feb 3, 2025Expand into selling wholesale with Shopify Academy’s learning path, B2B on Shopify: Lau...
By Shopify Jan 28, 2025