FROM CACHE - en_header

Find order by draftOrderId

Solved
ft3
Tourist
10 1 5

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?

Accepted Solution (1)

Accepted Solutions
2BDigital
Shopify Partner
152 37 48

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?

View solution in original post

Replies 2 (2)
2BDigital
Shopify Partner
152 37 48

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?

ft3
Tourist
10 1 5

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