Re: Remove Purchase button

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

Daniel19901
Shopify Partner
292 2 82

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:
https://woollenandkind.com/collections/sold-rugs/products/persian-6-6-x-3-4 (example product)

https://woollenandkind.com/collections/sold-rugs (collection)

 

Thank you in advance 

Reply 1 (1)

CodingSolution
Trailblazer
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 %}
banned