How to hide sold out products from search results in Shopify

Sell Online With Shopify
Trusted by millions of businesses worldwide
Sign up for a free trial and enjoy 3 months of Shopify for $1/month on select plans.

Displaying sold out products on search results could be a source of buyer frustration for clients, since customers could stumble upon products which are not for sale. This is especially relevant if your client is running a flash sale and customers are looking to reach available products quickly.

This is where we will be looking to customize.

  1. From your Shopify admin, go to Online Store > Themes.
  2. Find the theme you want to edit, and then click Actions > Edit code.
  3. In the Templates directory, click search.liquid to open it in the online code editor.
  4. Find to the loop {% for item in search.results %} and {% endfor %}.
  5. Add an IF statement between this FOR loop.
  6. Click Save and you’re done.

Before

After

Note: Since the sold out products are only hidden, this customization could have an affect on pagination. For example, if your search page is set to display 20 products, and five of the loaded products are sold out, you will only see 15 results. If you are seeing extreme cases of blank pages within pagination, you could adjust the pagination towards the max limit of 50 products per page.

Looking for Shopify Experts?

Hura Apps can help you take your store to the next level

Our team of experienced designers and developers can help you create a beautiful, high-converting Shopify store that will drive sales and increase customer satisfaction. From custom design to app development and optimization, we have the skills and expertise to help you achieve your eCommerce goals.

Get in touch

You may also like...

2 Responses

  1. chetan says:

    after using this code the sold out products are hidden but the title of the produts are shown

  2. Jakob says:

    This code worked in hiding the sold-out products, however, the search results are still counting all the products in the search and a majority of the pagination is showing blank pages. Is there code to fix this?

Leave a Reply

Your email address will not be published. Required fields are marked *