A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
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
Solved! Go to the solution
This is an accepted solution.
Hey @crpatel,
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
This is an accepted solution.
Hey @crpatel,
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
Do you have any information about how to retrive thoose data via GraphQl?
It seems the "note_attributes" only avalaible vie the REST api.
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
Waaaoooo Dude!!!!
You made my day!
Thank you for your advice and your examples as well.
Good Job! Keep it up!
hello Awwdam, please help me, i want to add customAttributes to one item of the line_items, how to write the mutation code, thank you very much.
Hi could you let me know how u added a check box gift message at check out? I can't seem to be able to do it ! thanks!
If you're trying to add notes to an existing checkout from within the actual checkout then I'd recommend looking at our documentation on Checkout UI extensions to see what's possible.
If you want to add a gift message box for capturing order notes to an online store's cart page, then I'd recommend following this tutorial or posting in our Online Store 2.0 board.
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