Development discussions around Shopify APIs
To continue receiving payouts, you need to secure your account by turning on two-step authentication. If two-step authentication is not turned on your payouts will be paused. Learn more
Hi there,
I am generating a draft order with the admin api, using this query:
mutation ($input: DraftOrderInput!) {
draftOrderCreate(input: $input) {
draftOrder {
invoiceUrl
}
userErrors {
field
message
}
}
}
Variables:
{
"input":{
"useCustomerDefaultAddress":true,
"tags":"Return",
"metafields":[
{
"namespace":"noni_returns",
"key":"order_reference",
"description":"Original order",
"value":"gid://shopify/Order/237645273645276",
"valueType":"STRING"
}
],
"customerId":"gid://shopify/Customer/87346583765",
"note":"Test comment",
"lineItems":[
{
"variantId":"gid://shopify/ProductVariant/284756293847",
"quantity":1
},
{
"variantId":"gid://shopify/ProductVariant/38475638475687",
"quantity":1
}
]
}
}
The draft order is created correctly, but when I convert it to an actual order by using the invoiceUrl only the tags and the note are carried over, the metafields are not.
Is there a way to attach meta information to a draft order that will show up in the resulting order?
Thanks in advance,
Leo
Hey @Leo_Bossmann ,
The behaviour of the metafield resource not being on the related order from the completed draft order is expected. As a possible work around, utilizing a draft_orders/update web hook would allow you the opportunity to migrate the metafields you want to the connected order when the draft order completes.
I think there's definitely value in auto creating the metafield on the resulting order, so I'll be sure to share this with the appropriate team.
Regards,
John
John C | Developer 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
Hi John,
I think there's definitely value in auto creating the metafield on the resulting order, so I'll be sure to share this with the appropriate team.
Thanks, I appreciate it!
For now I have worked around the problem by using custom attributes (additional details), but I'll look into the draft_orders/update webhook!
Take care,
Leo
Hey Leo,
I might actually like your approach better :-). The custom attributes get moved over already and you have that working. Maybe the web hook approach and migrating metafields yourself might not prove to be overly beneficial, but I'll leave that with you. If you have any other questions let me know.
Regards,
John
John C | Developer 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
@_JCC_ @Leo_Bossmann Just wanted to weigh in here and share an issue with using the custom attributes (note attributes) approach:
- Note attributes are not a good candidate to store information that should not be visible to customers; some integrations send the notes to back-end systems that may result in notifications being sent to the customer that include the note attribute
We would like the ability to add a (private) metafield to a draft order and ensure it is moved over to the order automatically.
That would allow us to store the technical information related to the draft order in a proper fashion.
User | RANK |
---|---|
5 | |
5 | |
4 | |
4 | |
4 |
Learn these 5 things I had to learn the hard way with starting and running my own business
By Kitana Jan 27, 2023Would you love to unleash the unbridled power of the Google Shopping Channel into your sho...
By Gabe Jan 6, 2023How can you turn a hobby into a career? That’s what Emmanuel did while working as a wa...
By Skye Dec 30, 2022