0
votes

I am unable to post items to Shopify cart using "/cart/add" with form action and multiple quantities of same variant id. When I try to add 6 quantities of the same variant id, the store cart shows me only 2 quantities that have been added.

I really don't want to use cart permalink as it skips cart page of store totally and from a remote site we can not call ajax api for the cart.

Can anyone help me with this issue?

<form id="addtocart" action="https://www.hotdiggity.dog/cart/add"        method="post"  enctype="multipart/form-data">
<input type="hidden" name="id[]" value="3013006977"/>
<input type="hidden" name="id[]" value="3013006977"/>
<input type="hidden" name="id[]" value="3013006977"/>
<input type="hidden" name="id[]" value="3013006977"/>
<input type="hidden" name="id[]" value="3013006977"/>
<input type="hidden" name="id[]" value="10304356999"/>
<input type="hidden" name="return_to" value="back" />
<input type="submit" value="Done" id="addToCartBut" class="cartpopupBut"/>

</form>
1
if you look very closely at you code you can see that the first 5 inputs have the same value - madalinivascu

1 Answers

0
votes

If I understood correctly, you're trying to add 6 units of the same variant to cart without using Ajax. In your code you're using two different variants and the fact that you repeat the same one 5 times won't make it add with quantity = 5. The way to do it, for a single variant is as per the following.

<form action="/cart/add" method="post">
  <input type="hidden" name="id[]" value="3013006977" />
  <input type="hidden" name="quantity" value="6" />
  <input type="hidden" name="return_to" value="/cart" />
  <input type="submit" value="BUY NOW" />
</form>

If you have to manipulate quantities of different variants and add them all together, you do need to go through the Ajax API they offer.