bulkCreateFulfillments( )


Creates multiple fulfillments for one or more orders.

The bulkCreateFulfillments() function returns a Promise that resolves when the fulfillments are created.

Authentication

This function requires elevated permissions and runs only on the backend and on dashboard pages.

Permissions
Manage Stores - all permissions
Manage Restaurants - all permissions
Manage eCommerce - all permissions
Manage Orders
Learn more about app permissions.
Method Declaration
Copy
function bulkCreateFulfillments(
  ordersWithFulfillments: Array<BulkCreateOrderWithFulfillments>,
): Promise<BulkCreateFulfillmentResponse>;
Method Parameters
ordersWithFulfillmentsArray<BulkCreateOrderWithFulfillments>Required

List of order IDs and their associated fulfillments' info.

Returns
Return Type:Promise<BulkCreateFulfillmentResponse>
JavaScript
import { orderFulfillments } from "wix-ecom-backend"; /* Sample ordersWithFulfillments value: * { * ordersWithFulfillments: [ * { * orderId: 'e613320a-8e8f-4f8f-9d87-b5edc9f99788', * fulfillments: [{ * lineItems: [{ * _id: '00000000-0000-0000-0000-000000000003', * quantity: 1 * }], * trackingInfo: { * trackingNumber: '93645', * shippingProvider: 'canadaPost' * } * }] * }, * { * orderId: 'a6c3a817-579d-4cb5-8521-2fe53b2c4bf1', * fulfillments: [{ * lineItems: [{ * _id: '00000000-0000-0000-0000-000000000001', * quantity: 1 * }], * trackingInfo: { * trackingNumber: '28674', * shippingProvider: 'usps' * } * }] * } * ] * }; */ export async function myBulkCreateFulfillmentsFunction(ordersWithFulfillments) { try { const newBulkFulfillments = await orderFulfillments.bulkCreateFulfillments( ordersWithFulfillments, ); const firstNewFulfillments = newBulkFulfillments.results[0].ordersWithFulfillments.fulfillments; const secondNewFulfillments = newBulkFulfillments.results[1].ordersWithFulfillments.fulfillments; console.log( "Success! Retrieved orders' fulfillments:", newBulkFulfillments, ); return newBulkFulfillments; } catch (error) { console.error(error); // Handle the error } } /* Promise resolves to: * * { * "results": [ * { * "itemMetadata": { * "_id": "e613320a-8e8f-4f8f-9d87-b5edc9f99788", * "originalIndex": 0, * "success": true * }, * "ordersWithFulfillments": { * "orderId": "e613320a-8e8f-4f8f-9d87-b5edc9f99788", * "fulfillments": [ * { * "_id": "397788c4-1c5b-40a3-9431-d4da8662a993", * "_createdDate": "2023-03-07T14:26:33.276Z", * "lineItems": [ * { * "_id": "00000000-0000-0000-0000-000000000002", * "quantity": 1 * } * ], * "trackingInfo": { * "trackingNumber": "93645", * "shippingProvider": "canadaPost", * "trackingLink": "https://www.canadapost.ca/cpotools/apps/track/personal/findByTrackNumber?trackingNumber=93645" * } * }, * { * "_id": "a875e4b7-c25d-4228-98e2-313ea6c07f95", * "_createdDate": "2023-03-07T14:23:59.426Z", * "lineItems": [ * { * "_id": "00000000-0000-0000-0000-000000000001", * "quantity": 1 * } * ], * "trackingInfo": { * "trackingNumber": "93645", * "shippingProvider": "canadaPost", * "trackingLink": "https://www.canadapost.ca/cpotools/apps/track/personal/findByTrackNumber?trackingNumber=93645" * } * }, * { * "_id": "e75bd872-69c9-427f-983a-280412161700", * "_createdDate": "2023-03-07T14:30:21.535Z", * "lineItems": [ * { * "_id": "00000000-0000-0000-0000-000000000003", * "quantity": 1 * } * ], * "trackingInfo": { * "trackingNumber": "93645", * "shippingProvider": "canadaPost", * "trackingLink": "https://www.canadapost.ca/cpotools/apps/track/personal/findByTrackNumber?trackingNumber=93645" * } * } * ] * } * }, * { * "itemMetadata": { * "_id": "a6c3a817-579d-4cb5-8521-2fe53b2c4bf1", * "originalIndex": 1, * "success": true * }, * "ordersWithFulfillments": { * "orderId": "a6c3a817-579d-4cb5-8521-2fe53b2c4bf1", * "fulfillments": [ * { * "_id": "a838877d-3f13-49f3-ab29-1cde478e0949", * "_createdDate": "2023-03-07T14:30:21.535Z", * "lineItems": [ * { * "_id": "00000000-0000-0000-0000-000000000001", * "quantity": 1 * } * ], * "trackingInfo": { * "trackingNumber": "28674", * "shippingProvider": "usps", * "trackingLink": "https://tools.usps.com/go/TrackConfirmAction.action?tLabels=28674" * } * } * ] * } * } * ], * "bulkActionMetadata": { * "totalSuccesses": 2, * "totalFailures": 0, * "undetailedFailures": 0 * } * } * */
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?