Add to cart button on checkout page works for second item in cart (from same product) not first

I am working on the cart page to code upsell volume discount. If I add only one variant to the cart of the product (with volume discount offer), the add to cart button does not work. However, if I add second variant then add to cart button works for both.

@KetanKumar

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

Please share your store URL.
So that I will check and let you know the exact solution here.

Can you please share your store url?

@dungenvishy

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

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

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

@KetanKumar @DelightCart @Zworthkey

Here is the preview link: https://x2z9qnrw8nzwzoao-56567005382.shopifypreview.com/

Below is the explanation. Go to the preview link and then to shop. Add Floppy Fish product to cart (any variant). Then go to cart. The cart page should look like this.

When on the cart page, you try to click on Add to cart, it does not work. Then you go to Shop again and add another variant of the Floppy Fish to the cart. It will look something like as shown in below image.

Now, the first Add to cart button does not work but the second one works.

Let me know what am I doing wrong. I am also sharing the code that I have used.

{% assign num = 0 %}
{% for item in cart.items %}
{% if item.product.handle contains “floppy” %}
{% capture temp %}{{ num | plus: item.quantity }}{% endcapture %}
{% endif %}
{% assign num = temp %}
{% endfor %}

{% assign new_num = num | plus: 0 %}

{% if item.product.handle contains “floppy” %}
{% if new_num == 1 %}

Add 1 more to get 15% discount!
{% elsif new_num == 2 %}
Add 1 more to get 20% discount!
{% elsif new_num == 3 %}
Add 1 more to get 25% discount!
{% endif %} {% endif %}

@dungenvishy

sorry i can’t see that fish product your store

@KetanKumar Do you want access to the store?

@dungenvishy

nope not can you please first send issue videp

https://www.loom.com/share/e44d88470cc0410bb71b6f583fe70098 @KetanKumar here is the video let me know if you have any questions