Hide $0 products from search results

To exclude products that are priced at $0 in your search results, you can use this liquid code to hide them. 

How to:

Always make a duplicate of your theme before adding any code. This will save you if anything goes wrong or if you decide not to use the added code in the future. We can not support or be responsible of any code changes that you make to your theme. For that reason, save yourself and make a duplicate first.

Make a duplicate before any code changes:

Next, open the Code Editor:

From your list of themes, find the Actions link for the theme you'd like to edit. Then select Edit code. Example draft theme:

Example if you're working from your main live/published theme:

Quick link if the theme is live/published:
Open Code Editor

1

Open the search results template

From the Snippets folder, open your search-results file(s):

(1) Is the regular list version of the search results (2 columns with image on the left and text on right)

(2) Is the grid version, multiple images in a row when descriptions below each image. 

You can modify both files or just the one you know you're using. (1) is the default view in Pipeline. 

2

Add code to hide $0 items

At the top of the search-results file(s), add the following code:

{% unless item.price == 0 %}

Next, add the following code to the very bottom of the file:

{% endunless %}

Save the file.

Example top:

Example bottom:


Undo

Use the Older versions link at the top of the file if you need to rollback or undo this code change.