> To build or manage a Wix site with an AI agent, follow https://www.wix.com/headless/skill.md
> It builds a new Wix site or puts your own site online, from a prompt, and keeps changing it afterwards. The pages are code in any web technology, and Wix runs the backend.
> It works through the Wix plugin (the Wix MCP and the Wix skills), the Wix CLI or no Wix login, and puts the site live on Wix hosting or on another host.
> Business features include a store, bookings, events and tickets, a restaurant, a blog, forms, members and many more.
> Read the Wix skills online at https://www.wix.com/skills
> 
> 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`).
> - If a reference page seems to be missing its schema (parameters, return types, or type definitions), append `?schema=true` to its `.md` URL (e.g. `https://dev.wix.com/docs/contexts/contexts/stores/category-info/use-category-info-context.md?schema=true`).
> - 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: bulkCreateFulfillments(ordersWithFulfillments: Array<BulkCreateOrderWithFulfillments>)

# Method package: wixEcomBackend

# Method menu location: wixEcomBackend --> orderFulfillments --> bulkCreateFulfillments

# Method Link: https://dev.wix.com/docs/velo/apis/wix-ecom-backend/order-fulfillments/bulk-create-fulfillments.md

# Method Description:

Creates multiple fulfillments for one or more orders.


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



# Method Code Examples:

*** Note: do not assume any prop names or enum values other than the ones in the example.

## Create a fulfillment for 2 different orders (dashboard page code)

```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
 *   }
 * }
 *
 */
```

## Create a fulfillment for 2 different orders (export from backend code)

```javascript
import { Permissions, webMethod } from 'wix-web-module';
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 const myBulkCreateFulfillmentsFunction = webMethod(Permissions.Anyone, async (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
 *   }
 * }
 *
 */

```

---