How to Hide Sold Out Variants or 0 Stock variants hide

Hi Shopify Community,

I am using the Pipeline theme for my Shopify store, and I would like to hide or remove sold-out variants from the product pages to improve the customer experience.

Currently, all variants (even those with zero stock) are visible in the variant selector, which may confuse customers. I want to ensure that only in-stock variants are displayed, or alternatively, make the sold-out variants unselectable.

Has anyone implemented this on the Pipeline theme? Could you guide me with the code or settings required to achieve this?

Thanks in advance for your help!`

2 Likes

Hello @Sharmila09
Thank you for submitting your query to the Shopify community. I’d be happy to assist you. Could you please provide the store URL and password (if it’s password-protected) so I can review and get back to you with an update?

@Sharmila09 Hi, I hope you are doing well..

To hide out-of-stock products in Shopify using Liquid code, you can modify your collection or product listing templates. Here’s an example of how to achieve this:

Step 1: Edit the Collection Template1. Go to Online Store > Themes in your Shopify admin.

  1. Click Actions > Edit code for your active theme.
  2. Locate the file where your products are being displayed. This is usually in collection.liquid or collection-template.liquid.

Step 2: Add a Condition to Hide Out-of-Stock Products

Find the loop that displays the products, typically using {% for product in collection.products %}. Add a condition to exclude products with zero inventory:

{% for product in collection.products %} 
{% if product.available %}   ## {{ product.title }} 

{{ product.price | money }}

 
 
{% endif %}
 {% endfor %}

Step 3: Save Changes

Save the file and refresh your store to see the updated product list.

Notes:- Inventory Tracking: Ensure that inventory tracking is enabled for your products. Without this, the product.available property won’t work as expected.

Editing Liquid files requires basic coding knowledge, so proceed carefully. If you’re unfamiliar with Liquid, consider consulting a Shopify expert.

Let me know if you need further help! :blush: