Edit Order: XXX was not added because it's already on the order.

Solved

Hi, 

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?

SPO - SEO App to research keywords & edit social link preview
BYOB - Build Your Own Bundles
0 Likes

When I try to add the repeated item to the order on the edit order page (in the portal), it's still OK.

But I can't do it with order edit API. Here are the screenshots:

show warning msgshow warning msg

repeated item is added without problemsrepeated item is added without problems

Is it a bug? Anyone?

SPO - SEO App to research keywords & edit social link preview
BYOB - Build Your Own Bundles
0 Likes
GrahamS
Shopify Staff
Shopify Staff
83 16 16

 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.

Graham S | API Support @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

0 Likes

Hi @GrahamS 

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. 

SPO - SEO App to research keywords & edit social link preview
BYOB - Build Your Own Bundles
0 Likes

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.

SPO - SEO App to research keywords & edit social link preview
BYOB - Build Your Own Bundles
0 Likes

This is an accepted solution.

It was my mistake. From the doc, just add allowDuplicates: true and the edit will be permitted.

SPO - SEO App to research keywords & edit social link preview
BYOB - Build Your Own Bundles
0 Likes