Complete fulfilment orders for different warehouses

Solved
RedYellowBlue
Tourist
8 0 1

Hi all, 

In the store we did assign product A to warehouse A and product B to warehouse B.

If an order had product A and B, the sales order results in two fulfilment orders. Which is correct and is what we want.

 

If warehouse A now send a tracking url to endpoint:
POST /admin/api/2021-07/fulfillments.json

We get an error: "None of the items are stocked at the new location."

So we did sent the location_id matching the assigned location id. This is not a 'new' location. I don't understand the error message for that part.

Then: none of the items? I did not specify items, because we fulfilled our fulfilment order completely. 

How is it possible that Shopify doesn't understand that if warehouse A POSTS a fulfilment order, that this fulfilment order is the order that was assigned to A. 

Both parties (A and B) want to keep working like we always did: just send to fulfillments.json what we did fulfill. Without attaching information like line_items. 

Regards, Peter

Accepted Solution (1)

Accepted Solutions
awwdam
Shopify Staff
Shopify Staff
241 40 30

This is an accepted solution.

Hey @RedYellowBlue

After taking a closer look, I wasn't able to replicate any bugs or unexpected functionality with fulfillment or fulfillment orders.

To clarify from our docs really quickly: "...A fulfillment order represents a group of one or more items in an order that are to be fulfilled from the same location". Generally, this would mean a minimum of one fulfillment order per location. If you have items from multiple locations on an order, more than one fulfillment (fulfillment_id) will be needed, again per location (location_id) or per fulfillment_order (fulfillment_order_id). 

This means that if you aren't specifically stating the line_item or fulfillment_order, as is the case in the example request you shared, the error returned would be expected. Specifically replicating a scenario like the one you shared, I was able to create and update fulfillments without error from a few different approaches:

The first can be done using two separate 
fulfillment requests, both would include a location_id and array of one or more line_item "id" per this example request. This generates fulfillment_id(s) that can then be used to update other data, and ultimately complete fulfillments for the order. 

The other method uses the fulfillment order resource and while the process is largely the same, instead of providing location_id we will need to query for all fulfillment_order "id" and fulfillment_order_line_items first. Once you have this info, two requests will also be required to process separate fulfillments from each fulfillment order, using the line_items_by_fulfillment_order array (example request). 


Hope that helps clarify or gives a new starting point, and that you are able to use the info above to find a solutions that fits best - Cheers!





awwdam | API Support @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

View solution in original post

Replies 5 (5)
RedYellowBlue
Tourist
8 0 1

So there are two fulfilment orders:

{
  "fulfillment_orders": [{
    "id": 4982117007546,
    "order_id": 4053182349498,
    "assigned_location_id": 62918459578,
    "request_status": "unsubmitted",
    ...
    "line_items": [{
      "id": 10494937170106,
      "fulfillment_order_id": 4982117007546,
      "quantity": 1,
      "line_item_id": 10380418908346,
      "inventory_item_id": 40166440599738,
      "fulfillable_quantity": 1,
      "variant_id": 38072997675194
    }],
    and another one...
  }]
}

 

Sending a POST request without any line_items results in:

    "fulfillment": {
      "tracking_company": CARRIER_NAME
      "location_id": LOCATION_ID,
      "tracking_number": BARCODE,
      "tracking_urls": [TRACKINGURL],
      "notify_customer": true
    }


Results in "None of the items are stocked at the new location."
Sending the same request including line items. Results in "Not Found".

If we put both products in the same warehouse, we then get 1 fulfilment order. And it is possible for me then to partially ship the order. With the same requests... 

So what is going on here Shopify?
Regards, Peter

 

awwdam
Shopify Staff
Shopify Staff
241 40 30

Hey @RedYellowBlue,

Thanks for sharing all of the example here - I took a closer look and have a few insights based on your current process.

In this case, two fulfillment_orders have been created, one for each line_item based on location. From my understanding, if the intention is to fulfill each line_item independently (multiple fulfillments), this would require a unique series of requests to process fulfillment per location. It is expected behaviour when multiple fulfillment orders are submitted in the same fulfillment request that they will be combined - per this doc.

There are some pretty comprehensive fulfillment resources here if you need additional references! Let me know if you run into any snags, I would be happy share any other insights! - Cheers!

awwdam | API Support @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

RedYellowBlue
Tourist
8 0 1

I will explain it a bit more with screenshots...

Test with two fulfilment orders
Two warehouse: one for B2C, one for B2B.

Screenshot 2021-09-13 at 10.35.24.png

The B2B Warehouse has: Big Product as product

Screenshot 2021-09-13 at 10.35.19.png

The B2C Warehouse has: Small Product as warehouse

When I create an order now, it results in two fulfilment orders: One for B2B Warehouse and one for B2C Warehouse:

Screenshot 2021-09-13 at 10.37.23.png

So far: All Good.

Now I send an API request as below:
url: /admin/api/2021-07/orders/4112281206983/fulfillments.json
POST

 

{ fulfillment: 
   { tracking_company: 'DHL Express',
     location_id: 65337262279,
     tracking_number: '3SHOPK602172701',
     tracking_urls: [ 'https://www.dhlparcel.nl/nl/consument/volg-je-pakket?tc=3SHOPK602172701&pc=9999AA' ],
     notify_customer: true } }

 

The result is:
{"errors":{"base":["None of the items are stocked at the new location."]}}

 

Test with one fulfilment order:

Another test with a new order with only one item. This results in a successful POST request:

Screenshot 2021-09-13 at 10.45.15.png

This was now set up in a completely new development store. Keep getting stuck. To my humble opinion this is a bug in Shopify.

 

Regards, Peter 

  

awwdam
Shopify Staff
Shopify Staff
241 40 30

This is an accepted solution.

Hey @RedYellowBlue

After taking a closer look, I wasn't able to replicate any bugs or unexpected functionality with fulfillment or fulfillment orders.

To clarify from our docs really quickly: "...A fulfillment order represents a group of one or more items in an order that are to be fulfilled from the same location". Generally, this would mean a minimum of one fulfillment order per location. If you have items from multiple locations on an order, more than one fulfillment (fulfillment_id) will be needed, again per location (location_id) or per fulfillment_order (fulfillment_order_id). 

This means that if you aren't specifically stating the line_item or fulfillment_order, as is the case in the example request you shared, the error returned would be expected. Specifically replicating a scenario like the one you shared, I was able to create and update fulfillments without error from a few different approaches:

The first can be done using two separate 
fulfillment requests, both would include a location_id and array of one or more line_item "id" per this example request. This generates fulfillment_id(s) that can then be used to update other data, and ultimately complete fulfillments for the order. 

The other method uses the fulfillment order resource and while the process is largely the same, instead of providing location_id we will need to query for all fulfillment_order "id" and fulfillment_order_line_items first. Once you have this info, two requests will also be required to process separate fulfillments from each fulfillment order, using the line_items_by_fulfillment_order array (example request). 


Hope that helps clarify or gives a new starting point, and that you are able to use the info above to find a solutions that fits best - Cheers!





awwdam | API Support @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

RedYellowBlue
Tourist
8 0 1

Hi, 

Thanks for your time to look at this issue. Both fulfilment companies fulfil orders with a location_id. 

In the front end in shopify, I can easily fulfil both fulfilment orders. These are my steps from our back-end:

Request:
GET: /orders.json?order=created_at asc

Response: (filtered out only the relevant parts)

 

{
  "id": 4112281206983,
  "app_id": 1354745,
  "line_items": [{
    "id": 10550566650055,
    "fulfillable_quantity": 1,
    "fulfillment_service": "manual",
    "fulfillment_status": null,
    "name": "Big Product",
    "origin_location": {
      "id": 3110096797895,
      "name": "B2C Warehouse",
    },
    "product_exists": true,
    "product_id": 6990829191367,
    "quantity": 1,
    "requires_shipping": true,
    "sku": "doos",
    "title": "Big Product",
    "variant_id": 40894028316871,
    "variant_inventory_management": "shopify",
    "variant_title": "",
    "vendor": "dozenverkoper",
  }, {
    "id": 10550566682823,
    "fulfillable_quantity": 1,
    "fulfillment_service": "manual",
    "fulfillment_status": null,
    "name": "Small Product",
    "origin_location": {
      "id": 3110096797895,
      "name": "B2C Warehouse",
    },
    "product_exists": true,
    "product_id": 6990828404935,
    "quantity": 1,
    "requires_shipping": true,
    "sku": "koker",
    "title": "Small Product",
    "variant_id": 40894026416327,
    "variant_inventory_management": "shopify",
    "variant_title": "",
    "vendor": "kokerverkoper",
  }],
  "refunds": [],
  "shipping_lines": []
}

 

 

I did even split up the origin location per product. So with getting the order, both fulfilment companies know they can only ship their own products. There is no overlap in products between the two fulfilment companies. 

The goal is that we can 'just' fulfil the order like if this was an order with only one fulfilment order attached. 

So this is the request as the B2C fulfilment company:
POST to /orders/4112281206983/fulfillments.json
body:

 

{ fulfillment: { location_id: 65337262279, tracking_number: null } }

 


response:

 

{"errors":{"base":["None of the items are stocked at the new location."]}}

 


I think this is still strange, because I want to fulfil all items from this location. And according to the documentation, this should be possible. No restrictions mentioned.


So now I will include the line items per your example:

 

{"fulfillment":{"location_id":65337262279,"tracking_number":null,"line_items":[{"id":10550566682823}]}}

 


Response:

 

{"fulfillment":{"id":3663221489863,"order_id":4112281206983,"status":"success" ... }}

 


So this works!!

I did test all kind of things before (with line items, without line items). At least a first successful response now. I'll keep on testing and implementing this in a live environment. 
Again thanks. 


Regards, Peter