Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

GraphQL orderEditAddCustomItem

Solved

GraphQL orderEditAddCustomItem

Kornemann
Tourist
4 1 0

Hi there i have installed shopify-graphiql-app and trying to run a mutation, not sure why I am getting this error, can anyone help here, thanks.

  1. mutation {
      orderEditAddCustomItem(id: "gid://shopify/Order/4413610786973", price: {amount: 300.00, currencyCode: USD}, quantity: 1, title: "MY CUSTOM THINGS") {
        calculatedLineItem {
          id
        }
        calculatedOrder {
          id
        }
        userErrors {
          field
          message
        }
      }
    }  
     
  2. this is the error I am getting
     
     
    "errors": [
        {
          "message": "invalid id",
          "locations": [
            {
              "line": 2,
              "column": 3
            }
          ],
          "path": [
            "orderEditAddCustomItem"
          ]
        }
      ],

    Please remember I have used all the required scopes.

Accepted Solution (1)
Kornemann
Tourist
4 1 0

This is an accepted solution.

hey, I got success If someone else is looking for this.
So here are the steps.
you need to have write_order_edits rights via scope when getting auth access token.

then you need to pass global order id of graphql mutation

first call mutation orderEditBegi

it will return calculated order id

then pass that calcualted order id into

mutation orderEditAddCustomIte

then at the end do call orderEditCommit with the same calcuated order id

and thats it, thanks.

View solution in original post

Replies 5 (5)

tewe
Shopify Partner
244 46 102

Hi @Kornemann ,

 

the id refers to a Calculated Order , see https://shopify.dev/api/admin-graphql/2022-01/objects/CalculatedOrder, so the ID should somehow like gid://shopify/CalculatedOrder/1832681575.

 

Have you seen the discussion here ?

 

Regards

Thomas

• Was my reply helpful? Click Like to let me know!
• Was your question answered? Mark it as an Accepted Solution
• Check out our Price Updater App
Kornemann
Tourist
4 1 0

Hey @tewe thanks for getting back, 

 

For now we have two ids, one `shopify_order_id` and other is `admin_graphql_api_id`

so you are saying in mutation 

 

```orderEditAddCustomItem(id: "gid://shopify/Order/44136107xxxxx", price: {amount: 300.00, currencyCode: USD}, quantity: 1, title: "MY CUSTOM THINGS") {```

 

I need to pass calculated order id?

if that is the case, then from where I can find that calculated order id.

All I need to do is to add a custom line item in the order.

can you please tell all the steps?

 

Kornemann
Tourist
4 1 0

moreover @tewe when i try to begin order edit with following mutation, I am getting calculated order id null.

 

mutation is 

 

mutation {
orderEditBegin(id: "gid://shopify/Order/44136107xxxx") {
calculatedOrder {
id
}
}
}

 

and response is

 

 

{
"data": {
"orderEditBegin": {
"calculatedOrder": null
}
},
"extensions": {
"cost": {
"requestedQueryCost": 10,
"actualQueryCost": 10
}
}
}

 

 

Kornemann
Tourist
4 1 0

This is an accepted solution.

hey, I got success If someone else is looking for this.
So here are the steps.
you need to have write_order_edits rights via scope when getting auth access token.

then you need to pass global order id of graphql mutation

first call mutation orderEditBegi

it will return calculated order id

then pass that calcualted order id into

mutation orderEditAddCustomIte

then at the end do call orderEditCommit with the same calcuated order id

and thats it, thanks.

Reynaldo_Zabala
Excursionist
11 0 10

Bonus points if you can figure out a way to do this from shopify flow where to my knowledge there is no way to currently assign a variable for use in another action...thoughts?