Re: Shopify 2.0 Dawn - How To Hide Unavailable Products from search

Shopify 2.0 Dawn - How To Hide Unavailable Products from search

binteamin2021
Excursionist
28 0 12

Please help with this. Been looking since forever.

Reply 1 (1)

DavidEKim
Shopify Partner
393 131 196

@binteamin2021 

Hi,

To hide unavailable product from search, you have to edit Snippets > card-product.liquid file.

Before editing the file, please make a backup file or backup your theme.

Please follow the steps below.

 

1. Go to Edit code > Snippets > card-product.liquid file.

2. Add the code below before <div class="card-wrapper underline-links-hover"> (line 33)

 

  {% unless card_product.available == false and template.name == 'search' %}

 

 

The above code is only for search results.

If you want to hide unavailable product completely from collection pages and sections, you can use the code below.

  {% unless card_product.available == false %}

 

It must be the same as below.

20230212_234505.png

 

3. Go to line 220 and add the code below.

 

  {% endunless %}

 

 

It must be added before {%- else -%} tag as below.

20230212_235142.png

 

4. Save the change and test your search.

 

In case you can't edit the code, please send me a private message.

Hope it helps.

 

 

 

 

 

If helpful, please Like and Accept Solution.
Want to customize your store, please feel free to contact me.
PeopleVillage - Shopify Partner