Changing locationId for lineItem in the order

Solved
Highlighted
New Member
1 0 0

Hi, I have two locations to fulfill orders from based on custom business logic.

And I am trying to find API-based alternative to the Shopify Admin UI for changing location of unfulfilled items of the order. The one the following screenshot

Screenshot 2020-03-22 16.07.55.png

 

 

I am trying to do it via GraphQL API 2020-01 mutation orderEditAddVariant whichaccepts argument locationIdThe ID of the location that this item will be fulfilled from.

per documentation https://shopify.dev/docs/admin-api/graphql/reference/mutation/ordereditaddvariant

mutation orderEditAddVariant($id: ID!, $variantId: ID!, $locationId: ID, $quantity: Int!) {
        orderEditAddVariant(id: $id, variantId: $variantId, locationId: $locationId, quantity: $quantity) {
          calculatedLineItem {
            id
          }
          calculatedOrder {
            id
          }
          userErrors {
            field
            message
          }
        }
      }

That looks exactly what I am looking for... Except I get an error when I try to pass locationId 

"userErrors":[{"field":["locationId"],"message":"Can't convert Integer to ShopIdentity::LocationId"}]

I tried all possible options there, double checked ids, etc. no luck

Currently I am thinking that this is a Shopify API bug. 

Please let me know how I can solve this

 

 

 

 

 

 

0 Likes
Highlighted
Shopify Staff (Retired)
Shopify Staff (Retired)
624 103 124

This is an accepted solution.

Hey @kinokritik ,

 

To change the location of where line items from an Order will be fulfilled from, if you are using API Version 2019-10 an above, you need to use the Fulfillment Order resource. You can read more about it here: https://shopify.dev/tutorials/manage-fulfillments-with-fulfillment-and-fulfillmentorder-resources

 

So in a nutshell in GraphQL API you need to use the mutation fulfillmentOrderMove https://shopify.dev/docs/admin-api/graphql/reference/mutation/fulfillmentordermove to change the fulfillment order (e.g. the group of line items being fulfilled together https://shopify.dev/docs/admin-api/graphql/reference/object/fulfillmentorder) to a new location ID

Hassain | Developer Support Specialist @ Shopify
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Click Accept as Solution 

1 Like