Skip to content

Commit 189cbb1

Browse files
committed
[api] Add reschedule action to FulfillmentOrder resource
1 parent 101cc52 commit 189cbb1

File tree

8 files changed

+98
-1
lines changed

8 files changed

+98
-1
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ default.
480480
- `list(orderId, fulfillmentId[, params])`
481481
- `update(orderId, fulfillmentId, id, params)`
482482
- fulfillmentOrder
483-
- `cancel(id, params)`
483+
- `cancel(id)`
484484
- `close(id[, message])`
485485
- `fulfillments(id)`
486486
- `get(id)`
@@ -489,6 +489,7 @@ default.
489489
- `locationsForMove(id)`
490490
- `move(id, locationId)`
491491
- `releaseHold(id)`
492+
- `reschedule(id, deadline)`
492493
- `setFulfillmentOrdersDeadline(params)`
493494
- fulfillmentRequest
494495
- `accept(fulfillmentOrderId[, message])`

resources/fulfillment-order.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,4 +159,22 @@ FulfillmentOrder.prototype.releaseHold = function releaseHold(id) {
159159
.then((body) => body[this.key]);
160160
};
161161

162+
/**
163+
* Reschedules a scheduled fulfillment order. Updates the value of the
164+
* `fulfill_at field` on a scheduled fulfillment order. The fulfillment order
165+
* will be marked as ready for fulfillment at this date and time.
166+
*
167+
* @param {Number} id Fulfillment Order ID
168+
* @param {String} deadline The new fulfillment deadline of the fulfillment
169+
* order
170+
* @return {Promise} Promise that resolves with the result
171+
* @public
172+
*/
173+
FulfillmentOrder.prototype.reschedule = function reschedule(id, deadline) {
174+
const url = this.buildUrl(`${id}/reschedule`);
175+
return this.shopify.request(url, 'POST', this.key, {
176+
new_fulfill_at: deadline
177+
});
178+
};
179+
162180
module.exports = FulfillmentOrder;

test/fixtures/fulfillment-order/req/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ exports.cancel = require('./cancel');
44
exports.close = require('./close');
55
exports.hold = require('./hold');
66
exports.move = require('./move');
7+
exports.reschedule = require('./reschedule');
78
exports.setFulfillmentOrdersDeadline = require('./set-fulfillment-orders-deadline');
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{ "fulfillment_order": { "new_fulfill_at": "2025-08-24 10:26 UTC" } }

test/fixtures/fulfillment-order/res/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ exports.list = require('./list');
99
exports.locationsForMove = require('./locations-for-move');
1010
exports.move = require('./move');
1111
exports.releaseHold = require('./release-hold');
12+
exports.reschedule = require('./reschedule');
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
{
2+
"fulfillment_order": {
3+
"id": 1046000788,
4+
"shop_id": 548380009,
5+
"order_id": 450789469,
6+
"assigned_location_id": 24826418,
7+
"request_status": "unsubmitted",
8+
"status": "scheduled",
9+
"fulfill_at": "2025-08-24T06:26:00-04:00",
10+
"supported_actions": ["mark_as_open"],
11+
"destination": {
12+
"id": 1046000788,
13+
"address1": "Chestnut Street 92",
14+
"address2": "",
15+
"city": "Louisville",
16+
"company": null,
17+
"country": "United States",
18+
"email": "bob.norman@mail.example.com",
19+
"first_name": "Bob",
20+
"last_name": "Norman",
21+
"phone": "+1(502)-459-2181",
22+
"province": "Kentucky",
23+
"zip": "40202"
24+
},
25+
"line_items": [
26+
{
27+
"id": 1058737492,
28+
"shop_id": 548380009,
29+
"fulfillment_order_id": 1046000788,
30+
"quantity": 1,
31+
"line_item_id": 518995019,
32+
"inventory_item_id": 49148385,
33+
"fulfillable_quantity": 1,
34+
"variant_id": 49148385
35+
}
36+
],
37+
"international_duties": null,
38+
"fulfillment_holds": [],
39+
"fulfill_by": null,
40+
"created_at": "2024-07-24T06:26:30-04:00",
41+
"updated_at": "2024-07-24T06:26:32-04:00",
42+
"delivery_method": null,
43+
"assigned_location": {
44+
"address1": null,
45+
"address2": null,
46+
"city": null,
47+
"country_code": "DE",
48+
"location_id": 24826418,
49+
"name": "Apple Api Shipwire",
50+
"phone": null,
51+
"province": null,
52+
"zip": null
53+
},
54+
"merchant_requests": []
55+
}
56+
}

test/fulfillment-order.test.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,4 +161,19 @@ describe('Shopify#fulfillmentOrder', () => {
161161
expect(data).to.deep.equal(output.fulfillment_order);
162162
});
163163
});
164+
165+
it('reschedules the fulfill_at time of a scheduled fulfillment order', () => {
166+
const input = fixtures.req.reschedule;
167+
const output = fixtures.res.reschedule;
168+
169+
scope
170+
.post('/admin/fulfillment_orders/1046000788/reschedule.json', input)
171+
.reply(200, output);
172+
173+
return shopify.fulfillmentOrder
174+
.reschedule(1046000788, '2025-08-24 10:26 UTC')
175+
.then((data) => {
176+
expect(data).to.deep.equal(output.fulfillment_order);
177+
});
178+
});
164179
});

types/index.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,10 @@ declare class Shopify {
391391
locationId: number
392392
) => Promise<Shopify.IFulfillmentOrder>;
393393
releaseHold: (id: number) => Promise<Shopify.IFulfillmentOrder>;
394+
reschedule: (
395+
id: number,
396+
deadline: string
397+
) => Promise<Shopify.IFulfillmentOrder>;
394398
setFulfillmentOrdersDeadline: (
395399
params: Shopify.ISetFulfillmentOrdersDeadline
396400
) => Promise<void>;

0 commit comments

Comments
 (0)