How to hide out of stock products [Free themes]
When you have an e-commerce store on Shopify it's normal to handle a wide variety of products, some of which sell more than others. That means sooner or later they'll run out of stock before you get a chance to replenish them with your supplier, and in the meanwhile you might not want them visible to your clients at all.
How to accomplish that might not be too obvious at first glance and some solutions can also cause other unintended bugs, such as leaving empty spaces in your collection page. This is no longer something you'll have to worry about however, as this tutorial will teach you how to easily hide any products that go out of stock.
This tutorial is compatible only with Shopify's official free themes: Colorblock, Craft, Crave, Dawn, Origin, Publisher, Refresh, Ride, Sense, Spotlight, Studio, Taste & Trade.
Looking to install this on a premium or custom theme? Contact us.
Making a backup of your theme
Before diving into the tutorial make sure you download the theme, so in case you face any issues you can easily revert back.
Hiding out-of-stock products at the collection page
-
From your Shopify admin, go to Online Store > Themes > Actions > Edict Code > Snippets > Add a new snippet
-
In the new box that appears type in:
ezfy-hide-sold-out
-
Inside the new file paste the following code and save your changes:
gist -
Find the file named exactly theme.liquid.
-
Inside this file, press CTRL + F (or CMD + F on Mac) and search for:
-
Paste the following code after the tag you found and save:
{% render 'ezfy-hide-sold-out' %}

Adding the code to the feature collection section
-
Find the file named:
featured-collection.liquid -
Inside this file, press CTRL + F (or CMD + F on Mac) and search for:
limit:
-
Copy the code below and paste above the line you found.
gist
-
Now, on the same line you found, replace this piece of text:
section.settings.collection.products
with this:
all_products
This is how it should look like: -
Now click on the save button and you're all set!
Conclusion
If your followed this guide through, any product that runs out of stock will be automatically hidden from the collection page and featured collection section, and once it's available again it'll reappear for your clients without you having to do anything.