Remove sold out items from sorting tags

Highlighted
Tourist
4 0 1

Basically, I am trying to create a new site with tag filters on the clothing items, so when you go to the new website preview here:

https://wv9bpn5l2jkz645s-15709401.shopifypreview.com

Then go to clothing and pick 'Outfits' for example. You will see the new tagged section on the left hand side of the page, which will filter sizes, colour etc.

At the moment however when i click a size, for example 4-5 years, and it narrows down the items. It works, but it still shows the items that are out of stock in this size. I want to NOT show the items in that size if that size is out of stock in the item, if this makes sense.

I have customers all the time asking what do you have available in certain sizes, so this is the reason for doing this. The current site (www.cutsiebobbs.co.uk), doesn't have any filtering options. This new tag filtering helps to an extent, but customers will complain still, as they have to go into every item to find what is in stock or not.

Hope someone can help.

Thanks

0 Likes
Highlighted
Shopify Staff
Shopify Staff
552 29 81

Hey!

My name is Ava, I’m one of Shopify’s Gurus and I’m here to help :)

If you would like to hide out of stock variants, then this guide will show you how to do that. This guide will only work on non-sectioned themes though, so it is best to check your theme settings first. To see if your theme has sections, you can go to the Themes page in your admin and click Actions > Edit code. If there are files in the Sections directory, then your theme is using Sections and this guide will not work for you. We do hope to update this guide soon to work with sectioned themes!

If your theme is using sections, then you can still use an app to hide sold out products/variants. Here are some examples below - 

 * WipeOut 
 * Zero Øut
 * AutoHide Soldout Products

Let me know if any of those solutions will work for you!

Ava

Social Care Guru | support@shopify.com
 

Ava | Social Care @ Shopify
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit the Shopify Help Center or the Shopify Blog

0 Likes
Highlighted
Tourist
4 0 1

Hi Ava,

I have tried that first solution before i posted this. This works great on products but i am looking to remove it from a collection when sold out. Since i am using tags to narrow down results, the tag is still attatched to the product so it shows up even if its sold out.

 

Is there anyway around this?

 

Thanks

0 Likes
Highlighted
Shopify Staff
Shopify Staff
552 29 81

Hey again!

Sorry to hear you're having trouble with this. As a workaround, you could try to set up an automated collection, setting the condition to be inventory is greater than 0

You can then add other conditions to pull the other products you would like to show in that collection. Could you let me know if that works for you? The apps I previously mentioned may still be the best way to hide out of stock products, but hopefully, this should do the trick!

Let me know how you get on :)

Ava

Social Care Guru | support@shopify.com

Ava | Social Care @ Shopify
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit the Shopify Help Center or the Shopify Blog

0 Likes
Highlighted
Tourist
4 0 1

Hi Ava,

This won't work for me as the side bar uses tags to narrow down the varients in the collection. 

Unless there is a way i can use automated collections for the side bar? But how would i do this? I can't see an option for this. 

 

The apps you suggested may work but i don't want to pay monthly for a small feature. I would rather pay once or work out a permanant solution.

 

Thanks

1 Like
Highlighted
New Member
5 0 0

I had a similar issue to this, (using the Supply theme) only I was already using smart collections with multiple options, matching ANY condition.  

 

Problem 1:  I wanted to only show items in stock, and since I already have multiple collection conditions, could not simply add a condition to match if inventory > 0.  This solution worked though, or more specifically:

 

Around line 94 in collection-template.liquid :

 

Change this:

 

{% include 'product-grid-item' with grid_item_width %}

 

To this:

 

 

{% if product.available %}
       {% include 'product-grid-item' with grid_item_width %}
{% endif %}

 

Problem 2:  Fixing this created another problem with unwanted filter tags showing in the sidebar, since the filters were still showing out of stock products, even though these products were not showing on the collection page any longer.    Here is my hacky fix:

 

In advanced-tag-loop.liquid :

 

Below this code...

 

{% if request.page_type == 'collection' and collection.all_tags.size > 0 %}

Insert this code:

 

{% assign stockedProductsTags = '' %}
{% for product in collection.products %}
{% if product.available %}
{% for tag in product.tags %}
   {% capture stockedProductsTags %}{% unless stockedProductsTags == blank  %}{{ stockedProductsTags }}|{% endunless %}{{ tag }}{% endcapture %}
{% endfor %}

{% endif %}
{% endfor %}
{% assign stockedProductsTags_array = stockedProductsTags | split: '|' | uniq %}

 

Then change this code:

 

 {% for tag in collection.all_tags %}

To this:

 

{% for tag in stockedProductsTags_array %}

 

Here is the entire advanced-tag-loop.liquid file after these changes:

 

{% comment %}
  A loop to catch and filter out the different tag categories.
  This is mainly for advanced tagging, but will also help us strip
  out any tag categories from our tags (E.g. remove BRAND_ from BRAND_tag)
{% endcomment %}
{% if request.page_type == 'collection' and collection.all_tags.size > 0 %}

{% assign stockedProductsTags = '' %}
{% for product in collection.products %}
{% if product.available %}
{% for tag in product.tags %}
   {% capture stockedProductsTags %}{% unless stockedProductsTags == blank  %}{{ stockedProductsTags }}|{% endunless %}{{ tag }}{% endcapture %}
{% endfor %}

{% endif %}
{% endfor %}
{% assign stockedProductsTags_array = stockedProductsTags | split: '|' | uniq %}


  {% assign categories = '' %}
  {% for tag in stockedProductsTags_array %}
    {% if tag contains '_' %}
      {% capture categories %}{% unless categories == blank  %}{{ categories }}|{% endunless %}{{ tag | split: '_' | first }}{% endcapture %}
    {% endif %}
  {% endfor %}
  {% assign cat_array = categories | split: '|' | uniq %}
{% endif %}

Essentially what's happening is I'm building a new array of products consisting only of those in stock, then capturing the tags for those products only.  Once that's done, you still need to fix collection-sidebar.liquid and change all instances of:

 

collection.tags

 to:

 

stockedProductsTags_array

Voila!   Hope it helps someone else.  It took me a couple of hours to figure it out.

 

0 Likes