> Portal Navigation: > > - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version. > - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages). > - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`). > - Top-level index of all portals: https://dev.wix.com/docs/llms.txt > - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt # Method name: createFulfillment(orderId: string, fulfillment: Fulfillment) # Method package: wixEcomBackend # Method menu location: wixEcomBackend --> orderFulfillments --> createFulfillment # Method Link: https://dev.wix.com/docs/velo/apis/wix-ecom-backend/order-fulfillments/create-fulfillment.md # Method Description: Creates an order fulfillment. The `createFulfillment()` function returns a Promise that resolves when the fulfillment is created. # Method Code Examples: *** Note: do not assume any prop names or enum values other than the ones in the example. ## Create a fulfillment (dashboard page code) ```javascript import { orderFulfillments } from 'wix-ecom-backend'; /* Sample orderId value: 'e613320a-8e8f-4f8f-9d87-b5edc9f99788'; * Sample fulfillment value: * { * lineItems: [{ * id: '00000000-0000-0000-0000-000000000001', * quantity: 1 * }], * trackingInfo: { * trackingNumber: '12345', * shippingProvider: 'dhl' * } * }; */ export async function myCreateFulfillmentFunction(orderId, fulfillment) { try { const newFulfillment = await orderFulfillments.createFulfillment(orderId, fulfillment); const fulfillmentId = newFulfillment.fulfillmentId; const newOrderFulfillments = newFulfillment.orderWithFulfillments.fulfillments; const trackingLink = orderFulfillments[0].trackingInfo.trackingLink; console.log('Success! Created new fulfillment:', newFulfillment); return newFulfillment; } catch (error) { console.error(error); // Handle the error } } /* Promise resolves to: * * { * "orderWithFulfillments": { * "orderId": "e613320a-8e8f-4f8f-9d87-b5edc9f99788", * "fulfillments": [ * { * "_id": "91357295-a95c-4973-b210-281640f3e795", * "_createdDate": "2023-03-06T15:23:29.967Z", * "lineItems": [ * { * "_id": "00000000-0000-0000-0000-000000000001", * "quantity": 1 * } * ], * "trackingInfo": { * "trackingNumber": "12345", * "shippingProvider": "dhl", * "trackingLink": "https://www.logistics.dhl/global-en/home/tracking.html?tracking-id=12345" * } * } * ] * }, * "fulfillmentId": "91357295-a95c-4973-b210-281640f3e795" * } * */ ``` ## Create a fulfillment (export from backend code) ```javascript import { Permissions, webMethod } from 'wix-web-module'; import { orderFulfillments } from 'wix-ecom-backend'; /* Sample orderId value: 'e613320a-8e8f-4f8f-9d87-b5edc9f99788'; * * Sample fulfillment value: * { * lineItems: [{ * id: '00000000-0000-0000-0000-000000000001', * quantity: 1 * }], * trackingInfo: { * trackingNumber: '12345', * shippingProvider: 'dhl' * } * }; */ export const myCreateFulfillmentFunction = webMethod(Permissions.Anyone, async (orderId, fulfillment) => { try { const newFulfillment = await orderFulfillments.createFulfillment(orderId, fulfillment); const fulfillmentId = newFulfillment.fulfillmentId; const newOrderFulfillments = newFulfillment.orderWithFulfillments.fulfillments; const trackingLink = orderFulfillments[0].trackingInfo.trackingLink; console.log('Success! Created new fulfillment:', newFulfillment); return newFulfillment; } catch (error) { console.error(error); // Handle the error } }); /* Promise resolves to: * * { * "orderWithFulfillments": { * "orderId": "e613320a-8e8f-4f8f-9d87-b5edc9f99788", * "fulfillments": [ * { * "_id": "91357295-a95c-4973-b210-281640f3e795", * "_createdDate": "2023-03-06T15:23:29.967Z", * "lineItems": [ * { * "_id": "00000000-0000-0000-0000-000000000001", * "quantity": 1 * } * ], * "trackingInfo": { * "trackingNumber": "12345", * "shippingProvider": "dhl", * "trackingLink": "https://www.logistics.dhl/global-en/home/tracking.html?tracking-id=12345" * } * } * ] * }, * "fulfillmentId": "91357295-a95c-4973-b210-281640f3e795" * } * */ ``` ---