Solved

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

Villiamjit
Shopify Partner
19 0 1

Hi Team,

 

I'm trying to create a new product variant with GraphQL API in the existing order.

 

here is the json code that I am using

 

{"query":"mutation orderEditAddVariant($id: ID!, $quantity: Int!, $variantId: ID!) {\r\n\t\t\t\t\torderEditAddVariant(id: $id, quantity: $quantity, variantId: $variantId) {\r\n\t\t\t\t\t\tcalculatedOrder {\r\n\t\t\t\t\t\t\tid\r\n\t\t\t\t\t\t\taddedLineItems(first:5) {\r\n\t\t\t\t\t\t\t edges {\r\n\t\t\t\t\t\t\t\t node {\r\n\t\t\t\t\t\t\t\t id\r\n\t\t\t\t\t\t\t\t quantity\r\n\t\t\t\t\t\t\t\t }\r\n\t\t\t\t\t\t\t }\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\tlineItems(first:10){\r\n\t\t\t\t\t\t\t\tedges {\r\n\t\t\t\t\t\t\t\t\tnode {\r\n\t\t\t\t\t\t\t\t\t id\r\n\t\t\t\t\t\t\t\t\t quantity\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t }\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tcalculatedLineItem {\r\n\t\t\t\t\t\t\tid\r\n\t\t\t\t\t\t\ttitle\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t userErrors {\r\n\t\t\t\t\t\tfield\r\n\t\t\t\t\t\tmessage\r\n\t\t\t\t\t }\r\n\t\t\t\t\t}\r\n\t\t\t\t}","variables":{"allowDuplicates":true,"id":"gid:\/\/shopify\/CalculatedOrder\/28891938905","quantity":1,"variantId":"gid:\/\/shopify\/ProductVariant\/12408611176537"}}

But I am getting an error that this item is not able to add it's already added. But as you see I added "allowDuplicates":true, in my query that is used to allow duplicate products with order edit.

{"data":{"orderEditAddVariant":{"calculatedOrder":null,"calculatedLineItem":null,"userErrors":[{"field":["id"],"message":"All things American Black Tank Top - Black \/ S was not added because it's already on the order."}]}},"extensions":{"cost":{"requestedQueryCost":29,"actualQueryCost":10,"throttleStatus":{"maximumAvailable":10000.0,"currentlyAvailable":9990,"restoreRate":500.0}}}}

 

Can anyone help me with this issue? as its really urgent for me to fix this.

 

Thanks,
Villiam

Screenshot_3.png

Accepted Solution (1)

ShopifyDevSup
Shopify Staff
1322 218 457

This is an accepted solution.

Hi @Villiamjit,

 

Thanks for your post. When using the orderEditAddVariant mutation in a test store with v2023-01 it's working as expected, returning that same error if the variant is already on the order unless allowDuplicates is set to true in which case it adds the item.

 

One thing that seems unusual about the example you provided is that in the return value calculatedOrder shows as null instead of showing some info about the calculatedOrder which could be a clue. As it is we have not been able to replicate that same problem with the information at hand.

 

Here's the query that was tested and which worked, perhaps trying this alternative formatting will help to track down what's going wrong:

 

mutation addVariantToOrder {
orderEditAddVariant(
 id: "gid://shopify/CalculatedOrder/47100000123"
 variantId: "gid://shopify/ProductVariant/3130000005456"
 quantity: 1
 allowDuplicates: true
) {
 calculatedOrder {
  id
  addedLineItems(first: 5) {
   edges {
    node {
     id
     quantity
    }
   }
  }
 }
 userErrors {
  field
  message
 }
}
}
 

If you're still having trouble after the above an option is to reach out to API support by choosing the Support option in the Partner dash, choosing the API option, and providing more specific details to enable a closer look at the environment.

 

Have a great day,
Jon551

 

Developer Support @ Shopify
- Was this reply helpful? Click Like to let us 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

View solution in original post

Reply 1 (1)

ShopifyDevSup
Shopify Staff
1322 218 457

This is an accepted solution.

Hi @Villiamjit,

 

Thanks for your post. When using the orderEditAddVariant mutation in a test store with v2023-01 it's working as expected, returning that same error if the variant is already on the order unless allowDuplicates is set to true in which case it adds the item.

 

One thing that seems unusual about the example you provided is that in the return value calculatedOrder shows as null instead of showing some info about the calculatedOrder which could be a clue. As it is we have not been able to replicate that same problem with the information at hand.

 

Here's the query that was tested and which worked, perhaps trying this alternative formatting will help to track down what's going wrong:

 

mutation addVariantToOrder {
orderEditAddVariant(
 id: "gid://shopify/CalculatedOrder/47100000123"
 variantId: "gid://shopify/ProductVariant/3130000005456"
 quantity: 1
 allowDuplicates: true
) {
 calculatedOrder {
  id
  addedLineItems(first: 5) {
   edges {
    node {
     id
     quantity
    }
   }
  }
 }
 userErrors {
  field
  message
 }
}
}
 

If you're still having trouble after the above an option is to reach out to API support by choosing the Support option in the Partner dash, choosing the API option, and providing more specific details to enable a closer look at the environment.

 

Have a great day,
Jon551

 

Developer Support @ Shopify
- Was this reply helpful? Click Like to let us 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