How can I remove the purchase button for sold out products?

Shopify Partner
82 0 10

Hi everyone,


I would like to remove the purchase button once a product is sold out. I made the settings in a a way that the products are added to the "sold out" collection once I have 0 stock.. in case it helps the coding part.


Hope someone can help: (example product) (collection)


Thank you in advance 

Reply 1 (1)

176 12 10

Find the section of the template that displays the purchase button. This may vary depending on your theme, but it's often within a form block or something similar. You'll need to add Liquid code to check if the product is sold out and conditionally hide the purchase button.

{% if product.available %}
  <!-- Display the purchase button when the product is available -->
  <button type="submit" name="add" id="AddToCart" class="btn">Add to Cart</button>
{% endif %}