Location Id is null after completed draft order

Solved
VinhLe
Tourist
4 0 0

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...
2. Update valid shipping address
https://shopify.dev/docs/admin-api/rest/reference/orders/draftorder?api[version]=2020-04#update-2020...
3. Complete Draft Order
https://shopify.dev/docs/admin-api/rest/reference/orders/draftorder?api[version]=2020-04#complete-20...
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!

0 Likes
SBD_
Shopify Staff
Shopify Staff
1071 143 189

This is an accepted solution.

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).

sivainguva
New Member
11 0 0

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

0 Likes