Add to cart button removed on collection pages when stock is 0

Highlighted
Excursionist
32 0 2

Hi everyone,

 

(Debut theme - www.bigplay.store)

 

Trying to find a solution to remove the add to cart button for sold out products on the collection page.

 

It seems when viewing the product itself, it prevents you from adding it to your cart, this is not the case on collection pages.

 

I have tried to find the button to wrap an if statement around it but with no luck. 

 

0 Likes
Highlighted
Globetrotter
629 60 68

I think your page already has removed add to cart button

you are welcome to contact me.
My email - suyash.patankar@gmail.com
1 Like
Highlighted
Excursionist
32 0 2

Oh I resolved myself by managing to correctly wrap the button in the statement! haha I will remove this :)

 

In case anyone else has the same issue - Edit: 

 

Actially here is the solution I used. Simply edit the product card :)

 

<form method="post" action="/cart/add">
<input type="hidden" name="id" value="{{ product.variants.first.id }}" />
<input type="submit" value="{% if product.variants.first.available%}Add to cart{% else %}Sold Out{% endif%}" class="btn" {% unless product.variants.first.available %}disabled{% endunless %} />
</form>

1 Like
Highlighted
Globetrotter
629 60 68

awesome.... congratulations.... just make sure that this works even when first variant not available but others are available

you are welcome to contact me.
My email - suyash.patankar@gmail.com
1 Like
Highlighted
Excursionist
32 0 2

Oh right, how would I test this?

0 Likes
Highlighted
Globetrotter
629 60 68

add stock to few variants apart from first one and check

you are welcome to contact me.
My email - suyash.patankar@gmail.com
1 Like