I'm trying to add some free items (set a 100% discount to the line item) to an order with Order Edit API. In the order, the customer also purchased the same XXX product separately. When I tried to add the free item, it just gave me this message.
I tried to add with orderEditAddVariant and then orderEditAddLineItemDiscount.
How can I resolve the issue?
Solved! Go to the solution
Hey @sillycube !
Rather than orderEditAddVariant, have you considered using orderEditSetQuantity? This still provided the calculatedLineItem output needed to utilize orderEditAddLineItemDiscount, but shouldn't encounter the same "Already exists on order" error.
Now, I'm trying to break an item into several items, e.g.:
item A (this item is non-existent in the inventory, just used for break-down) x 1 :$50
- item B x 1
- item C x 2
- item D x 1
Break down to:
item A x 1: $50
item B x 1: Free
item C x 2: Free
item D x 1: Free
Now let's say the customer buys an item B as a separate item, it's $30. When I use orderEditSetQuantity, how can I merge the discount with the free item x B? change quantity & calculate the % discount instead of applying 100% discount on item B? This makes it hard to recognize item B is a part of item A.
From the docs - Add a discount to the variant,
You can apply discounts only to new products and custom items that you add to the order.
If I edit the quantity of the line item, I cannot apply a discount. So orderEditSetQuantity is not working since it can't adjust the price.
This is an accepted solution.
It was my mistake. From the doc, just add allowDuplicates: true and the edit will be permitted.