> 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: listOrders(filters: FilterOptions, sorting: SortingOptions, paging: PaginationOptions, options: Options)

# Method package: wixPricingPlansBackend

# Method menu location: wixPricingPlansBackend --> Orders --> listOrders

# Method Link: https://dev.wix.com/docs/velo/apis/wix-pricing-plans-backend/orders/list-orders.md

# Method Description:

Lists pricing plan orders.

The `listOrders()` function returns a Promise that resolves to a list of up to 50 pricing plan orders.
 You can specify options for filtering, sorting, and paginating the results.

 This function returns the orders on the site. To list orders for the current member only, see the
 frontend [`listCurrentMemberOrders`](https://dev.wix.com/docs/velo/apis/wix-pricing-plans-frontend/orders/list-current-member-orders.md) function.


 > **Note**: Only site visitors with the **Manage Pricing Plans** and **Manage Subscriptions** [permissions](https://www.wix.com/my-account/site-selector/?buttonText=Select%20Site&title=Select%20a%20Site&autoSelectOnSingleSite=true&actionUrl=https:%2F%2Fwww.wix.com%2Fdashboard%2F%7B%7BmetaSiteId%7D%7D%2Froles-and-permissions/roles)
 > can list orders. You can override the permissions by setting the function's `suppressAuth`
 > option to `true`.



# Method Code Examples:

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

## List all orders

```javascript
import { Permissions, webMethod } from 'wix-web-module';
import { orders } from 'wix-pricing-plans-backend';

export const myListOrdersFunction = webMethod(Permissions.Anyone, async () => {
  try {
    const listedOrders = await orders.listOrders();

    return listedOrders;
  } catch (error) {
    console.error(error);
  }
});

// Promise resolves to an array of order objects.
```

## Bypass permission checks to list all orders

```javascript
import { Permissions, webMethod } from 'wix-web-module';
import { orders } from 'wix-pricing-plans-backend';

// Sample options object: { suppressAuth : true }

export const myListOrdersWithOptionsFunction = webMethod(Permissions.Anyone, async (options) => {
  try {
    const listedOrders = await orders.listOrders(null, null, null, options);
    const firstOrderId = listedOrders.orders[0]._id;
    const firstOrderStatus = listedOrders.orders[0].status;

    return listedOrders;
  } catch (error) {
    console.error(error);
  }
});

/* Promise resolves to an array of order objects--even if you do not have a role with 
 * permissions for listing orders.
 */
```

## Paginate and sort orders that match the specified filters

```javascript
import { Permissions, webMethod } from 'wix-web-module';
import { orders } from 'wix-pricing-plans-backend';

/* Sample filters object: 
 * {
 *   orderStatuses: ['PAUSED', 'CANCELED']
 * }
 */

/* Sample sorting object: 
 * {
 *   fieldName: ['createdDate'], 
 *   order: ['ASC']
 * }
 */

/* Sample paging object: 
 * {
 *   limit: 3,
 *   skip: 1
 * }
 */
export const myListOrdersWithFiltersFunction = webMethod(Permissions.Anyone, async (filters, sorting, paging) => {
  try {
    const listedOrders = await orders.listOrders(filters, sorting, paging);
    const firstOrderId = listedOrders.orders[0]._id;
    const firstOrderStatus = listedOrders.orders[0].status;

    return listedOrders;
  } catch (error) {
    console.error(error);
  }
});

/* Promise resolves to: 
 * [
 *   {
 *     "_id": "0d9c781c-d2d8-4e42-a9e6-60122ed47771",
 *     "planId": "a4d57b6c-42eb-4416-b8dd-196f1c321b78",
 *     "subscriptionId": "7b7f1800-da9a-4bf3-9e80-2eaef7e25f0c",
 *     "wixPayOrderId": "0010ea6a-a8cb-4b5d-a9fc-4ed1f337c623",
 *     "buyer": {
 *       "memberId": "fac761ea-e6f1-4e3d-8b30-a4852f091415",
 *       "contactId": "fac761ea-e6f1-4e3d-8b30-a4852f091415"
 *     },
 *     "priceDetails": {
 *       "subtotal": "33",
 *       "discount": "0",
 *       "total": "33",
 *       "planPrice": "33",
 *       "currency": "EUR",
 *       "singlePaymentForDuration": {
 *         "count": 6,
 *         "unit": "MONTH"
 *       }
 *     },
 *     "pricing": {
 *       "singlePaymentForDuration": {
 *         "count": 6,
 *         "unit": "MONTH"
 *       },
 *       "prices": [
 *         {
 *           "duration": {
 *             "cycleFrom": 1,
 *             "numberOfCycles": 1
 *           },
 *           "price": {
 *             "subtotal": "33",
 *             "discount": "0",
 *             "total": "33",
 *             "currency": "EUR"
 *           }
 *         }
 *       ]
 *     },
 *     "type": "OFFLINE",
 *     "orderMethod": "UNKNOWN",
 *     "status": "PAUSED",
 *     "lastPaymentStatus": "PAID",
 *     "startDate": "2022-06-27T13:35:22.979Z",
 *     "endDate": "2022-12-31T13:46:10.979Z",
 *     "pausePeriods": [
 *       {
 *         "status": "ENDED",
 *         "pauseDate": "2022-07-04T12:39:33.140Z",
 *         "resumeDate": "2022-07-04T12:50:21.637Z"
 *       },
 *       {
 *         "status": "ACTIVE",
 *         "pauseDate": "2022-07-04T14:22:45.006Z"
 *       }
 *     ],
 *     "earliestEndDate": "2022-12-27T13:46:11.475Z",
 *     "currentCycle": {
 *       "index": 1,
 *       "startedDate": "2022-06-27T13:35:22.979Z",
 *       "endedDate": "2022-12-31T13:46:10.979Z"
 *     },
 *     "planName": "One and Done",
 *     "planDescription": "",
 *     "planPrice": "33",
 *     "_createdDate": "2022-06-27T13:35:31.538Z",
 *     "_updatedDate": "2022-07-04T14:22:45.006Z"
 *   },
 *   {
 *     "_id": "a06b6a51-c815-44a1-a0f7-0af6cb4bbfda",
 *     "planId": "9f4ad2f3-d948-4daf-b517-eb2206b01ea1",
 *     "subscriptionId": "e2cbe3c4-322c-4530-b638-6076102e88ae",
 *     "wixPayOrderId": "b6c4a8b0-f7c1-480d-a2a9-68c5db566e16",
 *     "buyer": {
 *       "memberId": "f1654c62-53b4-43d5-b01b-acbf782dee6f",
 *       "contactId": "f1654c62-53b4-43d5-b01b-acbf782dee6f"
 *     },
 *     "priceDetails": {
 *       "subtotal": "9.99",
 *       "discount": "0",
 *       "total": "9.99",
 *       "planPrice": "9.99",
 *       "currency": "EUR",
 *       "singlePaymentUnlimited": true
 *     },
 *     "pricing": {
 *       "singlePaymentUnlimited": true,
 *       "prices": [
 *         {
 *           "duration": {
 *             "cycleFrom": 1,
 *             "numberOfCycles": 1
 *           },
 *           "price": {
 *             "subtotal": "9.99",
 *             "discount": "0",
 *             "total": "9.99",
 *             "currency": "EUR"
 *           }
 *         }
 *       ]
 *     },
 *     "type": "OFFLINE",
 *     "orderMethod": "UNKNOWN",
 *     "status": "PAUSED",
 *     "lastPaymentStatus": "PAID",
 *     "startDate": "2022-07-01T13:45:53.129Z",
 *     "pausePeriods": [
 *       {
 *         "status": "ENDED",
 *         "pauseDate": "2022-07-04T12:11:53.644Z",
 *         "resumeDate": "2022-07-04T12:37:33.089Z"
 *       },
 *       {
 *         "status": "ACTIVE",
 *         "pauseDate": "2022-07-10T09:57:23.919Z"
 *       }
 *     ],
 *     "currentCycle": {
 *       "index": 1,
 *       "startedDate": "2022-07-01T13:45:53.129Z"
 *     },
 *     "planName": "Gold",
 *     "planDescription": "Gold membership to the MyGame World of Online Gaming",
 *     "planPrice": "9.99",
 *     "_createdDate": "2022-07-04T11:21:14.790Z",
 *     "_updatedDate": "2022-07-10T09:57:23.919Z"
 *   },
 *   {
 *     "_id": "00739d76-edc0-4ce4-ab20-172bf09dd2f0",
 *     "planId": "9f4ad2f3-d948-4daf-b517-eb2206b01ea1",
 *     "subscriptionId": "2de691a9-7833-48e8-a3e0-3912d9896069",
 *     "wixPayOrderId": "b1204e93-ac5a-4116-9ad8-52e44017125a",
 *     "buyer": {
 *       "memberId": "f1654c62-53b4-43d5-b01b-acbf782dee6f",
 *       "contactId": "f1654c62-53b4-43d5-b01b-acbf782dee6f"
 *     },
 *     "priceDetails": {
 *       "subtotal": "9.99",
 *       "discount": "0",
 *       "total": "9.99",
 *       "planPrice": "9.99",
 *       "currency": "EUR",
 *       "singlePaymentUnlimited": true
 *     },
 *     "pricing": {
 *       "singlePaymentUnlimited": true,
 *       "prices": [
 *         {
 *           "duration": {
 *             "cycleFrom": 1,
 *             "numberOfCycles": 1
 *           },
 *           "price": {
 *             "subtotal": "9.99",
 *             "discount": "0",
 *             "total": "9.99",
 *             "currency": "EUR"
 *           }
 *         }
 *       ]
 *     },
 *     "type": "OFFLINE",
 *     "orderMethod": "UNKNOWN",
 *     "status": "PAUSED",
 *     "lastPaymentStatus": "PAID",
 *     "startDate": "2022-07-11T13:45:53.129Z",
 *     "pausePeriods": [
 *       {
 *         "status": "ACTIVE",
 *         "pauseDate": "2022-07-12T15:07:41.283Z"
 *       }
 *     ],
 *     "currentCycle": {
 *       "index": 1,
 *       "startedDate": "2022-07-11T13:45:53.129Z"
 *     },
 *     "planName": "Gold",
 *     "planDescription": "Gold membership to the MyGame World of Online Gaming",
 *     "planPrice": "9.99",
 *     "_createdDate": "2022-07-04T14:18:46.636Z",
 *     "_updatedDate": "2022-07-12T15:07:41.283Z"
 *   }
 * ]
 */
```

## Iterate through all pages of orders

```javascript
import { Permissions, webMethod } from 'wix-web-module';
import { orders } from 'wix-pricing-plans-backend';

// Retrieve all orders

export const myListAllOrdersFunction = webMethod(Permissions.Anyone, async () => {
  const ordersPerPage = 50;

  let pageNumber = 0;
  let currentOrdersPage = [];
  let allOrders = [];

  do {
    let ordersToSkip = { skip: pageNumber * ordersPerPage };
    try {
      currentOrdersPage = await orders.listOrders(null, null, ordersToSkip);
    } catch (error) {
      console.error(error);
    }
    allOrders = allOrders.concat(currentOrdersPage);
    pageNumber++;
  } while (currentOrdersPage.length != 0)

  return allOrders;
});
```

---