Metafields attached to draft order are not carried over to created order

Leo_Bossmann
Shopify Partner
6 0 2

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

0 Likes