Hide out-of-stock products using an liquid code change on theme files

Topic summary

Goal: hide sold‑out products on the home page collections and product detail pages using Liquid (Shopify’s templating language), not apps.

Initial guidance: suggestions to use automated collections or an inventory management app, and to consider hiding items in the default Catalog. A Shopify Flow doc was recommended as an alternative.

Preference: the requester explicitly asked for a code‑based solution, noting theme specifics may matter.

Latest update (solution): a Liquid conditional was shared to render product cards only when the product is in stock:

  • Check product.available == true before rendering the ‘card-product’ snippet.
  • This prevents out‑of‑stock items from appearing in collection grids/homepage product listings.
  • Reference: Shopify docs for product.available.

Outcome: a concrete code approach was provided by the requester; no further issues reported. The code snippet is central to understanding the resolution.

Status: effectively resolved with a Liquid condition; alternative non‑code methods (automated collections, Shopify Flow) remain viable if needed.

Summarized with AI on February 22. AI used: gpt-5.

Hi all.

I don’t want so the Sold out product on the home page collection and product details page.

Hide out-of-stock products using an liquid code change on theme files

Thanks for help

Hi @ErSanjay

You can use automated collections to hide out-of-stock products from your customers. You can do this manually on the Collections page of your Shopify admin, or use an inventory management app to do it for you.

You might also want to hide products in your store’s default Catalog collection.

Highly recommend reading this document.

@Boost_commner i want to hide with code

Hi @ErSanjay , in this case, we recommend you to contact a Shopify Expert or Theme Expert as this will depend on which theme you are using.

@Boost_Commerce

I know your team was an expert. have many great engineering solutions I fixed using the liquid

{%- when 'product' -%}
                      {%- capture product_settings -%}{%- if section.settings.product_show_vendor -%}vendor,{%- endif -%}title,price{%- endcapture -%}
                   {% if product.available == true %}   
                    {% render 'card-product',
                          card_product: item,
                          media_aspect_ratio: section.settings.image_ratio,
                          show_secondary_image: section.settings.show_secondary_image,
                          show_vendor: section.settings.show_vendor,
                          show_rating: section.settings.show_rating,
                          lazy_load: lazy_load
                        %}
                    {%- endif -%}

reference https://shopify.dev/api/liquid/objects/product?shpxid=5dd36f15-E244-4670-4217-7125EA382529#product-available

Thanks @Shopify_77 for batter documentation