Hello,
I have a product which has an orderlinefield for selecting a length. I want the customer to be able to select several quantities of several length and add them all to cart at once, but I'm struggling. It works when I only select a quantity and a length for only one line, but as soon as I select 2 or more, I get the attached error message : "An item with the same key has already been added."
Here is my rendered HTML :
<form method="post" id="multiForm" name="multiForm"> <input type="hidden" value="addMulti" id="CartCmd" name="CartCmd"> <div> <input type="hidden" value="1" id="ProductLoopCounter1" name="ProductLoopCounter1"> <input type="hidden" value="806" id="ProductID1" name="ProductID1"> <input type="hidden" value="" id="VariantID1" name="VariantID1"> <input type="hidden" value="" id="UnitID1" name="UnitID1"> <input type="hidden" value="0" id="wishListID1" name="wishListID1"> <input type="number" value="0" id="Quantity1" name="Quantity1"> <select id="EcomOrderLineFieldInput_SelectedLength1" name="EcomOrderLineFieldInput_SelectedLength1"> <!--options...--> </select> </div> <div> <input type="hidden" value="2" id="ProductLoopCounter2" name="ProductLoopCounter2"> <input type="hidden" value="806" id="ProductID2" name="ProductID2"> <input type="hidden" value="" id="VariantID2" name="VariantID2"> <input type="hidden" value="" id="UnitID2" name="UnitID2"> <input type="hidden" value="0" id="wishListID2" name="wishListID2"> <input type="number" value="0" id="Quantity2" name="Quantity2"> <select id="EcomOrderLineFieldInput_SelectedLength2" name="EcomOrderLineFieldInput_SelectedLength2"> <!--options...--> </select> </div> <div class="addtocart-bylength " id="addtocart-bylength-3"> <input type="hidden" value="3" id="ProductLoopCounter3" name="ProductLoopCounter3"> <input type="hidden" value="806" id="ProductID3" name="ProductID3"> <input type="hidden" value="" id="VariantID3" name="VariantID3"> <input type="hidden" value="" id="UnitID3" name="UnitID3"> <input type="hidden" value="0" id="wishListID3" name="wishListID3"> <input type="number" value="0" id="Quantity3" name="Quantity3"> <select id="EcomOrderLineFieldInput_SelectedLength3" name="EcomOrderLineFieldInput_SelectedLength3"> <!--options...--> </select> </div> <button type="submit" name="submit">Add to cart</button> </form>
I can't put my finger on what's wrong here. Any idea ?
Thanks !