Find order by draftOrderId

Solved
Highlighted
Tourist
9 1 3

I am trying to retrieve an order by draftOrderId. My expectation is that an orderId would be available via the `draftOrderComplete` mutation. However, that is not the case. Further, draftOrderId is not a supported filter parameter via the `orders` query. Is this currently possible? If not, are there any known work arounds?

0 Likes
Highlighted
Excursionist
80 19 19

This is an accepted solution.

Hi there

This should definitely be possible.

I presume you're using GraphQL based on your post.

So the draftOrder object has an order property that will get you the order that was completed from this draft.

So you can do this to get the first 10 draft orders and the orders that were completed on the back of that:

query getDraftOrders {
  draftOrders(first: 10) {
    edges {
      node {
        id
        createdAt
        completedAt
        order {
          id
          createdAt
        }
      }
    }
  }
}

So in your case - the DraftOrder that is returned from the draftOrderComplete mutation should have this "order" property that you can retrieve this information from?

0 Likes
Highlighted
Tourist
9 1 3

@2BDigital  -- I must have looked at the DraftOrder resource docs for an hour yesterday and missed the Order connection. 🤦‍ Thank you -- I appreciate it.

0 Likes