Update order fulfillment status using shopify API

Hello Support, I want to share one problem regarding the order update fulfillment status in the Shopify account using Shopify order API. I have set up a webhook in the ship station. When an order is created in Shopify, the order is also get added to the ship station at the same time. after that admin add a tax on that particular order and change the status (Shipped). When admin is updating an order from Shipstation then the same order in Shopify should be update to fulfillment status. I also calling an update order API to change the status but they are not reflecting in Shopify store. So could you please suggest me that change the fulfillment order status is possible in Shopify?

Firstly, you need to create a ā€œFulfillment Serviceā€ for your store.

To fulfill the orders, you need to

  1. Get list of fulfillment orders
    https://your-store-name.myshopify.com/admin/api/2022-10/orders/$shopify_order_id/fulfillment_orders.json

  2. For each of the fulfillment orders above, if the request status is ā€œunsubmittedā€ you need to submit fulfillment request

https:// your-store-name,myshopify.com/admin/api/2022-10/fulfillment_orders/$fulfillment_order_id/fulfillment_request.json

  1. Your fulfillment service will be able to accept the fulfillment request.

https:// your-store-name,myshopify.com/admin/api/2022-07/fulfillment_orders/$fulfillment_order_id/fulfillment_request/accept.json

  1. Create fulfillment(s) for the fulfillment order.

Request URL: https:// your-store-name.myshopify.com /admin/api/2022-07/fulfillments.json

Once you create fulfillment request, if the fulfillment request have all the details, the fulfillment order will be marked as fulfilled.

Thanks for the replay.
Can I pass two different location id? when I create a fulfillment request because the order comes from two different locations? when I pass the single location on fulfillment they can change the status but if the order comes from two different locations they cannot change the fulfillment status.

You cannot pass two locations, you have to fulfill the orders per location.

Which version of the API are you using? 2022-07

  1. You need to get the order ā€œFulfillment Orderā€ array
https://your-development-store.myshopify.com/admin/api/2022-07/orders/$shopify_order_id/fulfillment_orders.json

Loop through the ā€œfulfillment_ordersā€ array.

Send fulfillment request based on the assigned location, ā€œassigned_locationā€

In my own integration the process looks like this

// method getOrderFulfillments gets order "fulfillment orders"
     $orderfulfills = $this->getOrderFulfillments($shopify_order_id);

        if (is_array($orderfulfills) && count($orderfulfills) >0) {
            foreach ($orderfulfills as $rfill) {
                if (isset($rfill['request_status']) && $rfill['request_status'] =='unsubmitted' && isset($rfill['assigned_location']) && $rfill['assigned_location']['name'] =='My Own Fulfillment service') {

    // here I will send fulfillment request for all line item
      //The method sends request to the url below, 
    // https://your-development-store.myshopify.com/admin/api/2022-07/fulfillment_orders/$rfill['id']/fulfillment_request.json
    // with data similar to the data below.
   $data =array('fulfillment_request'=>array('message'=>'Order is ready for shipping',
        'fulfillment_order_line_items'=>array()) );

}

Hi,

As per Shopify 2022-07 version, the fulfillment API is deprecated. In your response, in step 4 you have mentioned to use fulfillment API endpoint. So can you please clarify?

Link : https://shopify.dev/api/release-notes/2022-07

You need to create a fulfillment for a fulfillment order.

https://shopify.dev/api/admin-rest/2022-07/resources/fulfillment

The fulfillment will have the tracking details and line items to fulfill, see the resources above for more details.

@deparagon

Sorry to ask the same question again..So are you saying that fulfillment api is not going to get deprecated though it says its deprecated as part of 2022-07? Can you please give more details?

Fulfillment is part of the new fulfillment order API

https://shopify.dev/api/admin-rest/2022-07/resources/fulfillment

The new fulfillment API above has not been deprecated

The old fulfillment API was deprecated, not the new one.

Hi @deparagon , I am following all the steps as mentioned above without creating a fulfillment_service app. Just by using the above APIs can I mark any order which has specific vendor product to ā€œfulfilledā€ using apis.
But getting error :

ā€œThe fulfillment order’s assigned fulfillment service must be of api typeā€

Is it neccessary to create a fulfillment app?

If you intent to fulfill orders on behalf of one or more stores, it is necessary that you create a fulfillment service.

Payload of new fulfillment service for a shop looks like this.

array(
            "name"                     => "Fulfillment Service Name",
            "callback_url"             => $callback_url,
            "inventory_management"     => false,
            "fulfillment_orders_opt_in"=> true,
            "tracking_support"         => false,
            "requires_shipping_method" => true,
            "format"                   => "json",
            "permits_sku_sharing"                   => true,

        );

When the fulfillment service is created, you will have the fulfillment service Id and also a Inventory location Id.

@deparagon

SCENARIO:
marketplace : A has shopify store
vendor : B is person who has to sell the product on A’s store
service: C is the service connecting them.

As C I have to pass on the information to B if any product from B vendor is in the order placed at A’s shopify store.

As service we don’t want to create a fulfillment app (which is available in shopify app store and needs to be installed), I just want to access the apis and acts as a fulfillment service:

I have created the fulfillment service using the api:

/admin/api/2023-01/fulfillment_services.json

In callback url, I am providing the our url which will listen the request from shopify.

But I am not getting any notification when order is created. I was expecting for order fulfillment request notification.
But I have not created any fulfillment app which is present on play store, I am just trying to

access apis directly . Is it possible to do the above without creating separate fulfillment app using PHP.

You do not need to create a separate app. The fulfillment App in this scenario is ā€œYour fulfillment Serviceā€

This is the correct steps.

  1. When a shopify shop installs your shopify App.
    You need to add this shop to your ā€œfulfillment serviceā€; Create a new ā€œfulfillment serviceā€ for the new shop.

…/admin/api/2023-01/fulfillment_services.json endpoint

  1. Subscribe new Shopify shop to shopify webhook ā€œorders/paidā€; With this your internal system will know when order is placed and paid.

  2. Foreach product variant that the shop uploads to Shopify store, you need to set the fulfillment_service property to the handle of your fulfillment service.

Example: If your fulfillment service name is ā€œGreen Shop Fulfillmentā€, your fulfillment service handle will likely be ā€œgreen-shop-fulfillmentā€
So each product variant will have a property
$variant->fulfillment_service = ā€˜green-shop-fulfillment’;
The step above will ensure that all your inventory is in the location created by the fulfillment service.

  1. When order is placed, your webhook (orders/paid) receives and stores order information. When your internal system has prepared the order for shipping. Your next step will be to get the order fulfillments.

assume 450789469 is shopify order id;
/admin/api/2023-01/orders/450789469/fulfillment_orders.json
More info here
https://shopify.dev/api/admin-rest/2023-01/resources/fulfillmentorder#get-orders-order-id-fulfillment-orders

  1. Loop through the result of fulfillment_orders request and check for fulfillment orders with assigned_location name equal to your fulfillment service name.
    a) sendfulfillmentrequest
    b) accept fulfillment request
    c) create fulfillments

This is all you need

1 Like

@deparagon Thanks a lot for your help and time!!
I think this will solve my problem :blush: