Splitting fulfilmentOrder for a single line item

Splitting fulfilmentOrder for a single line item

david-dotdev
Visitor
2 0 1

Hi, I'm trying to find a way to split up fulfilmentOrder for a line item in a Shopify order.

An example situation would be:

  • Shopify store has multiple locations, call them location A (default) and location B, and the store is set to track inventory at locations.
  • A product is created in the store with 1 inventory quantity in both A and B, totalling of 2 items across all locations.
  • A customer purchases the item with quantity 2 from the online store
  • As according to the behaviour set out in this documentation, the line item is being set to location A for both quantities, even though location A only has 1 (because neither A nor B has 2 of the said item)
  • This results in location A's inventory to go -1, and location B to stay at 1.

In the above scenario, the said order will have a fulfilmentOrder attached to it for the line item to be fulfilled at location A. What I wanted to do is to actually split it out (via GraphQL API) so that 1 is assigned to location A and the other to location B, resulting in both locations having 0 inventory at the end and none having negative inventory.

The only GraphQL mutation I can find that might be relevant is fulfilmentOrderMove, but it does not allow splitting an existing fulfilmentOrder. Does anyone know how to achieve this? Many thanks!

Replies 3 (3)

_JB
Shopify Staff (Retired)
836 100 223

Hey @david-dotdev,

In the scenario you described, the recommended workflow is to first create a fulfillment for 1 unit at the assigned location. Once the fulfillment is created, the existing fulfillment_order will have it's fulfillable_quantity updated to 1, at which point it can be moved to the new location using the  fulfilmentOrderMove mutation.

JB | Solutions Engineer @ Shopify 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

develop
Shopify Partner
11 0 8

Hello, JB can you explain me how to create this fulfillment, because I can see Shopify creates the fulfillment automatically when an order is created, but can't find how to create one with the rest API 

develop
Shopify Partner
11 0 8

To answer myself you can create new fulfillments for and order to split it in several shiptments, here is how I do it:

 

{"fulfillment":{"message":"Envio generado.","notify_customer":true,"tracking_info":{"number":123123123,"url":"https://www.example.com","company":"example"},"line_items_by_fulfillment_order"
[{"fulfillment_order_id":5967621062821"fulfillment_order_line_items":[ {"id"12404202274981"quantity"1} ]}]}}
 
A very important detail is that the id on "fulfillment_order_line_items" is not the line_item id from order endpoint but the one you get from the array line_items from the result of calling this endpoint: /admin/orders/ORDER_ID_XXXX/fulfillment_orders.json
 
So I already split the order , the next step is to setup the location we want the shipping from, I guess thats when you use the move.json endpoint (https://shopify.dev/api/admin-rest/latest/resources/fulfillmentorder#post-fulfillment-orders-fulfill...)
 
Anyone can confirm this is the correct flow to generate multiple shipments from one order?