"Add to Cart" Disabled when OOS

Fern21
New Member
3 0 0

Hello,

I was wondering if someone can breakdown for me how the "add to cart" button grays out when the variant does not have any stock?

I am currently learning to become a shopify dev and was wondering if someone can help me out? Also, if you have any helpful resources on how you learned liquid please drop the links in the comment section, that'll be much appreciated! 

0 Likes

Hi @Fern21,

You need to add JS code to check variant and then add disabled for button, it will help button become gray.

Code:

if (variant && variant.available) {
in stock
} else {
out stock
}

You can also find documents at: https://shopify.dev/api/liquid/objects

Hope it helps!

If you find my answer helpful for you, please mark it as a solution. Thank you and good luck

LitExtension - #1 Shopping Cart Migration Expert
If our answer is helpful then please accept as solution!
Are you looking for a solution to migrate to Shopify? Contact us for further assistance.
Try our FREE DEMO now!
0 Likes