API: How to unfulfill a refunded order

Highlighted
New Member
2 0 0

Hi there,

 

We are using order fulfillment status in our backend system as a flag of providing a customer with a good. Automatic fulfillment is enabled and all normal orders are marked fulfilled automatically. But when we refund an order, the fulfillment status is not being nulled automatically. That is OK and we decided to do it from the backend - when order is refunded, we want to null its fulfillment status (or set it to something else rather than 'fulfilled' or 'partial')

 

But we are failing to do it via REST API. Node.js and shopify-api-node are used.

 

Here is what I tried to do with a refunded order:

 

for (const f of order.fulfillments) {
    const fulfillmentResult = await this.getClient().fulfillment.cancel(f.order_id, f.id);
}

 

Status of the fulfillments are being changed to 'canceled' as per fulfillmentResult object, but order fulfillment status is still 'fulfilled'.

 

const orderResult = await this.getClient().order.update(order.id, {
    id: order.id,
    fulfillment_status: 'restocked',
    line_items: order.line_items.map(li => {
        return { id: li.id, fulfillment_status: 'not_eligible' } as IOrderLineItem;
    }),
} as IOrder);

Nothing is changed. I have tried setting different values to fulfillment_status properties, including 'null' - the same result.

 

It looks like I am wrong in some predictions of how the order fulfillment status works.

Test payments are being used if this matters.

The question is not about code, but about the way of doing it - unfulfilling refunded order via REST API.

 

Please help!

 

Regards,
Mikhail

0 Likes
Highlighted
New Member
2 0 0

Hi all,

 

Does anybody know something related to the topic?

 

Thanks,

Mikhail

0 Likes