-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.
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!
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"
}
]
}
}
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.