Ad

Add To Cart Button Not Working In One Div But Works Well Everywhere Else - Shopify Liquid

- 1 answer

I'm trying to have a potw section on my home page. It only showcases 1 product from a collection and there's an Add to Cart button next to it that should add it to the cart but it isn't doing anything currently and I can't figure out why. I am using Timber and I have the exact same syntax on as I do on the product.liquid template.

Ad

Answer

You need to tell it the id of the product/ variant you are trying to add. Try adding this somewhere within the <form> element:

<input type="hidden" name="id" value="{{ product.variants.first.id }}">
Ad
source: stackoverflow.com
Ad