how to add additional details to the order once it is created?

Solved
chiragramjibhai
Shopify Partner
12 0 0

Hello all,

I am stuck at some point and hope for some help.

My Goal:

Add Gift message to the order

-add gift message while creating order online(by the customer)

-add gift message while creating manual order(from Shopify admin)

-add gift message to already created order(from Shopify admin - order could have been created from online store by customer or from Shopify admin by staff)

 

In my POC I was able to add gift message to the order in the cart page using "note_attributes". But this works for order placed on the online store by the customer. After that I am not able to find a way to add gift message to the already created order or manual order.

 

Note: I do not want to use cart note. I am using this to store some other details.

 

I really appreciate your help...

 

Thanks

Accepted Solution (1)

Accepted Solutions
awwdam
Shopify Staff
Shopify Staff
249 42 33

This is an accepted solution.

Hey @chiragramjibhai,

Based on my testing, I was able to update the "note_attributes" on an existing order that I created through the admin - I'd suggest using the example provided in our docs here as a starting point! - Cheers!

awwdam | 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

View solution in original post

Replies 4 (4)
awwdam
Shopify Staff
Shopify Staff
249 42 33

This is an accepted solution.

Hey @chiragramjibhai,

Based on my testing, I was able to update the "note_attributes" on an existing order that I created through the admin - I'd suggest using the example provided in our docs here as a starting point! - Cheers!

awwdam | 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

Radixsecur1ty
Shopify Partner
10 2 2

Do you have any information about how to retrive thoose data via GraphQl?
It seems the "note_attributes" only avalaible vie the REST api.

awwdam
Shopify Staff
Shopify Staff
249 42 33

Hey @Radixsecur1ty,

It is possible to retrieve this data in GraphQL via a query for orders.customAttributes. If you don't have an example to test, it is also possible to append note_attributes using a orderUpdate mutation, including customAttributes [AttributeInput!], formatted as an array of key-value pairs. Note: per the documentation, this overwrites any existing customAttributes on the order object.

I have included examples of a query and mutation below:

 

// Query

{
  order(id: "gid://shopify/Order/{{ID}}") {
    id
    customAttributes {
      key
      value
    }
  }
}

 

 

 

// Mutation 

mutation orderUpdate($input: OrderInput!) {
  orderUpdate(input: $input) {
    order {
      id
      customAttributes {
        key
        value
      }
    }
    userErrors {
      field
      message
    }
  }
}

// Query Variables 

{
  "input": {
    "id": "gid://shopify/Order/{{ID}}",
    "customAttributes": [
      {
        "key": "NAME",
        "value": "This is a note"
      }
    ]
  }
}

 

 


Cheers!

awwdam | 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

Radixsecur1ty
Shopify Partner
10 2 2

Waaaoooo Dude!!!!

You made my day! 
Thank you for your advice and your examples as well.

Good Job! Keep it up!