Changing locationId for lineItem in the order

Solved

Changing locationId for lineItem in the order

kinokritik
Tourist
6 0 13

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

 

 

 

 

 

 

Accepted Solution (1)

hassain
Shopify Staff (Retired)
624 104 188

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

To learn more visit the Shopify Help Center or the Community Blog.

View solution in original post

Replies 4 (4)

hassain
Shopify Staff (Retired)
624 104 188

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

To learn more visit the Shopify Help Center or the Community Blog.

freelance_dev
Tourist
3 0 3

What if you wanted to change the fulfillment location of a specific line item in the group of line items listed in the FulfillmentOrder. How would you accomplish that?

The mutation fulfillmentOrderMove applies to all line items grouped under a FulfillmentOrder. But it does not allow a developer change the fulfillment location of individual line items in the group unless non-targeted line items are constrained in some way (line item is fulfilled, or fulfillment location's stock level can't cover the line item quantity).

Is there an API endpoint available that supports changing the fulfillment location of a specific line item in a FulfillmentOrder?

jakelous
Shopify Partner
3 0 4

This solution is not an acceptable solution, as noted by Freelance_dev. OP and I need to know how to change the location for a LineItem, and not a group of products. It is crazy to me that the API input "locationId" on the mutation "orderEditAddVariant" does nothing. When I add the variant to the order, it is assigned to the default fulfilment group, regardless of location input. Please help us out! Thanks.

Jake
JoesIdeas
Shopify Partner
2411 223 644

I would like to know how to do this too, with the new Fulfillment Order API. Used to be able to easily change location of an item with the Fulfillment API by just setting the location.

 

How do change the location of a line item with the REST API?

 

Example: Order comes in with 2 items assigned to location A. I want to move item 2 to location B.

• Creator of Order Automator [auto tag, fulfill, connect FBA, order jobs]
• Co-Creator of Product Automator [suite of features for products / collections]
• Shopify developer for 10+ years, store owner for 7 years
• Blog: Shopify Tips, Guides, and Automation Tools