Add to cart button not appearing on all products in collection page

sam_san
New Member
2 0 1

Hi everyone, 

I coded the add to cart button to appear on my collection page under every product, but somehow it only shows under certain products and not others, I think it's because some of the variants in that product are out of stock. Does anyone have a fix for this issue? I also coded an "out of stock" button to show on the collection page, could that be interfering? I'm attaching a screenshot for reference.

Screen Shot 2021-04-28 at 12.36.15.png

Screen Shot 2021-04-28 at 12.39.13.png

 

Thanks!

KetanKumar
Shopify Partner
17242 1869 6450

@sam_san 

Sorry you are facing this issue, it would be my pleasure to help you.

Welcome to the Shopify community!
Thanks for your good question.

Please share your site URL,
I will check out the issue and provide you a solution here.

If helpful then please Like and Accept Solution.
Want to modify or custom changes on store Hire me.
- Feel free to contact me on bamaniyaketan.sky@gmail.com regarding any help
Shopify Expert | Skype : bamaniya.sky
PSD to Shopify | Shopify Design Changes | Shopify Custom Theme Development and Desing | Custom Modifications In to Shopify Theme | SEO & Digital Marketing
0 Likes
sam_san
New Member
2 0 1

Hi @KetanKumar thank you so much,

Here's the url: https://red-hot-100.myshopify.com/

password: drahst 

0 Likes
KetanKumar
Shopify Partner
17242 1869 6450

@sam_san 

thanks for store URL

if you are able to code please try this product card or product-list item file otherwise let me know 

<form action="/cart/add" method="post">
{% if product.variants.size == 1 %}
<input type="hidden" name="id" value="{{ product.variants.first.id }}" />
{% else %}
<select name="id">{% for variant in product.variants %}<option value="{{ variant.id }}">{{ variant.title }}</option>{% endfor %}</select>
{% endif %}
<div><button type="submit" name="add">Add to cart</button></div>  
</form>

 

If helpful then please Like and Accept Solution.
Want to modify or custom changes on store Hire me.
- Feel free to contact me on bamaniyaketan.sky@gmail.com regarding any help
Shopify Expert | Skype : bamaniya.sky
PSD to Shopify | Shopify Design Changes | Shopify Custom Theme Development and Desing | Custom Modifications In to Shopify Theme | SEO & Digital Marketing
0 Likes