When applying certain promotions/discounts, VTEX returns in its response the same item (same skuID) split in two (could be more): one with the discount applied to it, and the other with the normal price.
This creates a problem for the backend, since to edit/delete an item you use the index (position within the array) and not the skuId. Then, in order to to change the quantity of an item, the quantity of duplicates would also have to be set to 0. Furthermore, the order is random: the discounted item can be at the beginning or at the end.
Is there a way to avoid this split? Or has anyone faced this situation and found a workaround?
The options I see
When obtaining the response: group the elements with the same skuId, adding their quantities, discounts, etc. so as to return a collection of items with no repetitions.
When calling handleItems to modify the cart: set the quantity of all items to 0 and send again al the items with index set to null.