Re: How to fulfill an order by using respective API?

Solved

How to fulfill an order by using respective API?

Abubakar8144
New Member
11 0 0

I am trying to fulfill an order by using the respective API. But when I try fulfillment call it asks me about fulfillment_id.

How can I get fulfillment_id by using respective API? Kindly help me in this problem.

 

My request sample:

https://my_development_store/admin/api/2021-10/orders/450789469/fulfillments/fulfillment_id.json

 

My json request body:

{

   "orders" :

{

          "fulfillment_id" : fulfillment_id,

           "order_id"  :  450789469

 }

}

Accepted Solutions (2)

ktbishop
Shopify Partner
22 1 3

This is an accepted solution.

The fulfillment_id is the unique identifier for a Fulfillment in Shopify. The request url you posted makes it seem like you're trying to use this PUT endpoint  which updates an existing fulfillment, and that is probably why the fulfillment_id is required.

If you're trying to create a fulfillment for an Order or a FulfillmentOrder you might try one of these POST endpoints instead:

Create a fulfillment for one or many fulfillment orders - requires you to specify which fulfillment order/fulfillment order line items you're fulfilling

Create a new Fulfillment - requires you to specify which order and line items you're fulfilling

I hope this helps!

 

Kyle B.

View solution in original post

JuanGrasso
Shopify Partner
20 3 4

This is an accepted solution.

You can fulfill an order is by fulfilling the N fulfillment-orders that compound the order.


The workflow would be to get all the fulfillments orders asociated to an order: Doc Here

You get an array with the N fulfimments orders that compount the order. 

Then you should get the id of each of those fulfillment orders and fulfill each of them: Doc Here

 

Once you had fulfilled all the fulfillments orders of the order, the order would be fulfilled.

 

I hope that it help you.

 

EDIT: Make sure you have this access scope so you can have access to the fulfill fulfillments orders api.

  • write_merchant_managed_fulfillment_orders

View solution in original post

Replies 14 (14)

ktbishop
Shopify Partner
22 1 3

This is an accepted solution.

The fulfillment_id is the unique identifier for a Fulfillment in Shopify. The request url you posted makes it seem like you're trying to use this PUT endpoint  which updates an existing fulfillment, and that is probably why the fulfillment_id is required.

If you're trying to create a fulfillment for an Order or a FulfillmentOrder you might try one of these POST endpoints instead:

Create a fulfillment for one or many fulfillment orders - requires you to specify which fulfillment order/fulfillment order line items you're fulfilling

Create a new Fulfillment - requires you to specify which order and line items you're fulfilling

I hope this helps!

 

Kyle B.
Abubakar8144
New Member
11 0 0

Thank you!

It worked. The fulfillment was created. 

But, while creating a fulfillment, the location_id we passed in json request body is assigned_location_id otherwise it gives an error. 

My josn request body :

{
  "fulfillment": {
    "location_id"63770493081,
    "tracking_number"null,
    "line_items": [
      {
        "id"10945997471897
      }
    ]
  }
}

JuanGrasso
Shopify Partner
20 3 4

This is an accepted solution.

You can fulfill an order is by fulfilling the N fulfillment-orders that compound the order.


The workflow would be to get all the fulfillments orders asociated to an order: Doc Here

You get an array with the N fulfimments orders that compount the order. 

Then you should get the id of each of those fulfillment orders and fulfill each of them: Doc Here

 

Once you had fulfilled all the fulfillments orders of the order, the order would be fulfilled.

 

I hope that it help you.

 

EDIT: Make sure you have this access scope so you can have access to the fulfill fulfillments orders api.

  • write_merchant_managed_fulfillment_orders
Abubakar8144
New Member
11 0 0

I have tried and I am able to get the fulfillment_id by using respective API.

My request sample :

https://my-development-store.myshopify.com/admin/api/2021-10/orders/order-id/fulfillment_orders.json

 

But when I tried for the create a fulfillment call by using respective API it didn't work.

 

My request sample :

https://my-development-store.myshopify.com/admin/api/2021-10/orders/order-id/fulfillments.json

 

My Json request body :

{
  "fulfillment": {
    "location_id"1234345452,
    "tracking_number"null,
    "line_items": [
      {
        "id"102345561711
      }
    ]
  }
}

 

Response:

{
    "errors""Not Found"
}
 
Kindly help me regarding this problem.
Thank you in advance!
 
SCHLUE1
Tourist
6 1 3

Hello JuanGrasso - Thank you for replying to my inquiry. I did check into the links, which you provided, and I am still not quite sure how to accomplish what needs to be accomplished.

Currently we are posting the below data to a specific Order_ID in order to change the fulfillment status of the order to fulfilled:

{
"fulfillment" : {
"location_id" : XXXXXXXXXXX,
"tracking_company" : "USPS",
"tracking_numbers" : [ "9405511205159866681224" ],
"notify_customer" : "true",
"send_fulfillment_receipt" : "true",
"send_receipt" : "true",
"line_items" : [ {
"id" : 11730858246343,
"quantity" : 1
} ]
}
}

 

When looking at the different Endpoint options for Posting to the FulfillmentOrder API, I don't see any Endpoint which appears to contain this functionality. I only see "POST" Endpoints for this API with the following functionality:

 

* Cancel a fulfillment order
* Mark a fulfillment order as incomplete
* Apply a fulfillment hold
* move a fulfillment to a new location
* mark the fulfillment as open
* release a fulfillment hold on a fulfillment order
* reschedule the fulfill_at time of a scheduled fulfillment order

 

I am probably missing something, so if you could point me in the right direction, that would be much appreciated.

 

Thanks!!

colleenc
Shopify Partner
91 9 21

Hi @SCHLUE1 I am losing my mind trying to accomplish the same as you. Everything I can find assumes I have access to the fulfillment id or the fulfillment order id, but if I have not yet fulfilled the order, the ids do not exist.

 

It would be helpful if @Shopify detailed how to create those ids.

 

Please let me know if you figure this out. I have posted up where I am at if you would like to look at the path I am following, it's here: https://community.shopify.com/c/user/viewprofilepage/user-id/888415#:~:text=REST%20Fulfillment%20Cre...

SCHLUE1
Tourist
6 1 3

Hello Colleenc,

I have not tested the following due to having to work at a different project, but you could try the below:
1. Use a URI with the following structure: https://XYZ-Prodbox.myshopify.com/admin/orders/<orderid>/fulfillment_orders.json
(please note the use of "fulfillment_orders.json" - instead of "fulfillments.json")
2. The <orderid>, which is passed within the above URI, would contain the shoporder - not the fulfillment order
3. The following link describes how to retrieve a list of fulfillment orders for a specific order (the response returns the shoporder)
https://shopify.dev/api/admin-rest/2021-10/resources/fulfillmentorder#get-orders-order-id-fulfillmen...

Hopefully that will work!

 

colleenc
Shopify Partner
91 9 21

Thanks for the quick response! Unfortunately, this doesn't work. I have tried all the versions of GET that I can find with both fulfillment & fulfillment_order and none of them seems to work. I will keep plugging away because I have to solve this. I will update you with any findings as you are going down the same path that I am.

 

SCHLUE1
Tourist
6 1 3

I was able to use the following Get successfully via Postman:

https://XYZ-sandbox.myshopify.com/admin/orders/<ABCD>/fulfillment_orders.json

ABCD is the "regular" order Id

 

I hope that this helps!

 

This did give me the following response (just snippet shown):

{"fulfillment_orders":[{"id":Fullfillment_orders.ID,"shop_id":XXXXX,"order_id":ABCD,

colleenc
Shopify Partner
91 9 21

I have managed to pull in the fulfillment order id via the GET call that you recommended above.

 

I have the JSON to send the data back to the store "working" too, however, it isn't adding the tracking data to the store and it isn't fulfilling the orders. I can't figure out where I have gone wrong unless there is another step that I have missed in all of this.

 

API: https://xxx.myshopify.com/admin/api/2022-10/fulfillments.json

 

JSON:

{
	"fulfillment": {
		"line_items_by_fulfillment_order": [{
			"fulfillment_order_id": {api.id},
			"fulfillment_order_line_items": [{Line Items Fulfillment Array}]
        }],
          "tracking_info": {
			"company": "{Fulfillments: Tracking Company}",
			"number": {Fulfillments: Tracking Number},
			"url": "{Tracking URL}"
		},
		"notify_customer": false,
		"location_id": {api.assigned_location_id}
	}
}

 

colleenc
Shopify Partner
91 9 21

Hello my https://fragrance-lodge.myshopify.com/admin/api/2020-04/orders/{Order: Id}/fulfillments.json is not working/has been deprecated armageddon peeps!

 

With a lot of help from @Ralph-HA @IGIT @SCHLUE1  and others, it is solved.

 

THIS PROCESS IS WORKING!

 

Pay attention to the details, as a tiny detail can mess you up for days...ask me how I know...

 

Step One: GET Fulfillment_Orders API

 

This step creates the fulfillment and returns the fulfillment_order_id that you need.

 

GET

https://xxx.myshopify.com/admin/api/2022-10/orders/{Order : Id}/fulfillment_orders.json

 

Note: Make sure you use fulfillment_orders and not fulfillments.

 

This will send you: api.id, api.shop_id, api.order_id, etc., which you need for the next step. Use the api.id for the next step as it is the fulfillment_order_id, do not use api.order_id  as it is the order_id.

 

Step two: POST to API (or use your method of choice)

 

API: https://xxx.myshopify.com/admin/api/2022-10/fulfillments.json

 

JSON:

 

{
	"fulfillment": {
		"line_items_by_fulfillment_order": [{
    		"fulfillment_order_id": {api.id},
            "line_items": [{Line Items Fulfillment Array}]
  }],
      "tracking_info": {
          "company": "{Fulfillments: Tracking Company}", 
          "number": {Fulfillments: Tracking Number}, 
          "url": "{Tracking URL}"
      },
		"notify_customer": false,
		"location_id": {api.assigned_location_id}
	}

 

 

And that's it! You are done.

Ralph-HA
Shopify Partner
107 7 46

Hi @colleenc,

   Great to hear you got it to work and I'm happy I was able to help!  You're right, everything is driven from the Fulfillment Order ID. 

 

Good Luck!

Co-Founder / Developer at Highview Apps
Our Shopify Apps: EZ Exporter | EZ Inventory | EZ Importer | EZ Notify | EZ Fulfill
colleenc
Shopify Partner
91 9 21

This post deleted.

colleenc
Shopify Partner
91 9 21

I was close, but the previous code was fulfilling the whole order rather than the shipped items only. I have it now and posted it here:

 

https://community.shopify.com/c/shopify-apis-and-sdks/rest-fulfillment-creation-help-please/m-p/1766...