Closed Harshpanday closed 1 year ago
You need to create a fulfillment for the order, not update the order.
Hey @lpinca I actually am trying to create a fulfillment order now but am facing some issues I would be grateful if you could check my question on Stackoverflow (https://stackoverflow.com/questions/76492758/unable-to-create-fulfill-request-and-accept-request-for-order) out and give me some pointers.
In your SO example, you don't need to specify the fulfillment_order_id
. It is already specified as the first argument of shopify.fulfillmentRequest.create()
. Also, you can usually get more details on 422 responses by reading error.response.body
, where error
is the error with which the promise was rejected.
Thank you for taking a look at it @lpinca .
Without fulfillment_order_id
I still get the same error and error.response.body
shows the following
{
errors: [
"The fulfillment order's assigned fulfillment service must be of api type"
]
}
I fixed it. To whoever facing a similar issue read the following The fulfillment order's assigned fulfillment service must be of api type Fulfill order
Now in my case I am testing on a fake store before going into production. All my orders items have fulfillment_service
as manual
, so I can directly set the Fulfillment Statement
in the shopify store as fulfilled
.
In order to do that I need to use fulfillment.createV2(params)
.
Here is an example
//Get fulfillment_details of an order
const fulfillment_details = await shopify.order.fulfillmentOrders(order_id)
//The id that you'll get from the above fulfillment_details is the fulfillment_order_id (we need that to fulfill an item)
//Map the id and fulfillment_id of lineitems to a variable
const fulfillment_order_id = fulfillment_details[0].id
const fulfillment_lineitem_ids = fulfillment_details[0].line_items.map( i =>{
return{
"id":i.id,
"quantity":i.quantity
}
})
//Using the fulfillment_order_id and fulfillment_lineitem_id create parameters as follows
params={
"line_items_by_fulfillment_order":[
{
"fulfillment_order_id":fulfillment_order_id,
"fulfillment_order_line_items":fulfillment_lineitem_ids
}],
"tracking_info":{
"number":"1234",
"url":"www.usps.com",
"company":"Fake Company"
},
"notify_customer":false,
"origin_address":null,
"message":"test message"
}
//Create a fulfillment update for the order
const test = await shopify.fulfillment.createV2(params)
I recently started using this library and I am facing a similar issue. I am trying to update the fulfillment_status of my order, but for some reason it is not getting updated. Here is my code
In console, the order getting printed is the correct order but the fulfillment status is still null. I tried updating other parameters too, but nothing gets updated.