Location Id is null after completed draft order

I used Shopify API to created order.

Steps created order:

Created draft order → Update valid shipping address → complete draft order → Get order info (location_id is null).

Call API steps:

  1. Call API to create draft order:
    https://shopify.dev/docs/admin-api/rest/reference/orders/draftorder?api[version]=2020-04#create-2020-04
  2. Update valid shipping address
    https://shopify.dev/docs/admin-api/rest/reference/orders/draftorder?api[version]=2020-04#update-2020-04
  3. Complete Draft Order
    https://shopify.dev/docs/admin-api/rest/reference/orders/draftorder?api[version]=2020-04#complete-2020-04
  4. Get order
    https://shopify.dev/docs/admin-api/rest/reference/orders/order?api[version]=2020-04#show-2020-04
    => location_id is null.

How can you help know about for issue?

Thanks!

Hey @VinhLe

This is expected. location_id is the ID of the physical location where the order was processed, which will usually be null (unless the order was placed via POS).

1 Like

I modified the graphql query file and updated the api

mutation {
draftOrderCreate(input: {
customerId: “$userId”,
customAttributes: [
#if( $quoteId )
{
key: “Quote ID”,
value: “$quoteId”
}
#end
#if( $poNumber )
{
key: “PO Number”,
value: “$poNumber”
}
#end
]
#if( $note )
note: “$note”
#end
#if ( $tags )
tags: “$tags”
#end
lineItems: [
#foreach( $lineItem in $lineItems )
{
variantId: “$lineItem.id”
quantity: $lineItem.quantity

requiresShipping: $lineItem.shipping.required
              #if( $lineItem.attributes )
                 customAttributes: [
                   #foreach( $attribute in $lineItem.attributes.entrySet() )
                       {
                           key: "$attribute.key"
                           value: "$attribute.value"
                       },
                   #end
                 ]
              #end

}
#end
]
}) {
draftOrder {
id
invoiceUrl
}
userErrors {
field
message
}
}
}

so if I add the lineitem shipping it throws the same null pointer exception

Hey SBD_ ,

When an order is placed from our website, location_id populates and maps to our 3PL based on the customers physical location.

However, when we place a draft order, location_id is null. What can we do to populate location_id for draft orders, too? We’re entering the customers physical location/ship to address and want it to map to the correct 3PL.

1 Like