Search.../

listOrders( )

Lists pricing plan orders.

Description

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 function.

Note: Only site visitors with the Manage Pricing Plans and Manage Subscriptions permissions can list orders. You can override the permissions by setting the function's suppressAuth option to true.

Syntax

function listOrders([filters: FilterOptions], [sorting: SortingOptions], [paging: PaginationOptions], [options: Options]): Promise<Array<Order>>

listOrders Parameters

NAME
TYPE
DESCRIPTION
filters
Optional
FilterOptions

Filter options for limiting which orders are listed.

sorting
Optional
SortingOptions

Sorting options, such as by which property and in which direction.

paging
Optional
PaginationOptions

Pagination options, such as how many results are listed at a time.

options
Optional
Options

Options to use when listing orders.

Returns

Fulfilled - Pricing plan orders that match the specified filtering, sorting, and pagination options.

Return Type:

Promise<Array<Order>>
NAME
TYPE
DESCRIPTION
_id
string

Order ID.

planId
string

ID of the plan that was ordered.

subscriptionId
string

ID of the related Wix subscription.

Every pricing plan order corresponds to a Wix subscription, including orders for single payment plans. You can see all orders from your site's Subscriptions page in the Dashboard.

wixPayOrderId
string

ID of the associated Wix Pay order.

Created by the createOnlineOrder() or createfflineOrder() function. For online orders, send this value as a parameter to the Wix Pay startPayment() function to enable your buyer to pay for the order. wixPayOrderId is omitted if the order is free.

buyer
Buyer

The buyer's IDs. Includes memberId and contactId.

Currently, Pricing Plan orders are limited to members only. contactId is returned, but a buyer will not be able to order a plan without a memberId.

priceDetails
PriceDetails

Deprecated. Use pricing instead.

pricing
Pricing

Order pricing model, price, and payment schedule.

type
string

How the order was processed. Supported values:

  • "ONLINE". The buyer ordered the plan using the site.
  • "OFFLINE". The buyer made a manual, offline order without using the site.
status
string

Status of the order. Supported values:

  • "DRAFT". The order has been initiated but payment hasn't been processed yet. The plan isn't yet available for use.
  • "PENDING". The order has been processed and its start date is set in the future. The plan isn't yet available for use.
  • "ACTIVE". The order has been processed. The plan is available for use.
  • "PAUSED". The order, and use of the plan, is paused. For example, if the buyer is away. The order, and use of the plan, can be resumed.
  • "ENDED". The order has completed its duration and is no longer available for use.
  • "CANCELED". The order has been canceled.
autoRenewCanceled
boolean

Whether the order will be canceled at the next payment date.

If true, the order status will be CANCELED and the next payment won't be charged. Omitted for single payment orders.

cancellation
Cancellation

Details about the cancellation of an order. Only present if the status is "CANCELED".

lastPaymentStatus
string

Status of the last payment for the order. This is updated automatically for online orders. The site owner updates this manually for offline orders. Supported values:

  • "PAID". The last payment was paid.
  • "REFUNDED". The last payment was refunded.
  • "FAILED". The last payment transaction didn't complete.
  • "UNPAID". The last payment wasn't paid.
  • "PENDING". Awaiting payment.
  • "NOT_APPLICABLE". No payment was necessary. For example, for free plans or free trials.
startDate
Date

Start date and time for the ordered plan.

endDate
Date

Current date and time the ordered plan will expire.

endDate may be updated over the course of an order. If the order is paused, it will have a later endDate once it resumes. endDate may also be postponed.

Omitted if the order is valid until canceled and still "ACTIVE".

pausePeriods
Array<PausePeriod>

List of periods during which this order is paused.

freeTrialDays
string

Free trial period, in days. Only available for recurring plans.

earliestEndDate
Date

Earliest end date and time that the plan for this order can expire.

This is calculated by adding all pause periods to the original end date. Omitted if the order is active until canceled. Reserved for future use.

currentCycle
CurrentCycle

Current payment cycle for the order.

currentCycle will be omitted if the order's status is CANCELED or ENDED, or if the startDate hasn't passed yet.

planName
string

Name of the plan at the time of the order.

planDescription
string

Description of the plan at the time of the order.

planPrice
string

Plan price as it was at the moment of order creation.

_createdDate
Date

Date and time the order was created.

_updatedDate
Date

Date and time the order was last updated. For example, the date and time an order was paused, resumed, or canceled.

Was this helpful?

List all orders

Copy Code
1import { Permissions, webMethod } from 'wix-web-module';
2import { orders } from 'wix-pricing-plans-backend';
3
4export const myListOrdersFunction = webMethod(Permissions.Anyone, async () => {
5 try {
6 const listedOrders = await orders.listOrders();
7
8 return listedOrders;
9 } catch (error) {
10 console.error(error);
11 }
12});
13
14// Promise resolves to an array of order objects.
Bypass permission checks to list all orders

Copy Code
1import { Permissions, webMethod } from 'wix-web-module';
2import { orders } from 'wix-pricing-plans-backend';
3
4// Sample options object: { suppressAuth : true }
5
6export const myListOrdersWithOptionsFunction = webMethod(Permissions.Anyone, async (options) => {
7 try {
8 const listedOrders = await orders.listOrders(null, null, null, options);
9 const firstOrderId = listedOrders.orders[0]._id;
10 const firstOrderStatus = listedOrders.orders[0].status;
11
12 return listedOrders;
13 } catch (error) {
14 console.error(error);
15 }
16});
17
18/* Promise resolves to an array of order objects--even if you do not have a role with
19 * permissions for listing orders.
20 */
Paginate and sort orders that match the specified filters

Copy Code
1import { Permissions, webMethod } from 'wix-web-module';
2import { orders } from 'wix-pricing-plans-backend';
3
4/* Sample filters object:
5 * {
6 * orderStatuses: ['PAUSED', 'CANCELED']
7 * }
8 */
9
10/* Sample sorting object:
11 * {
12 * fieldName: ['createdDate'],
13 * order: ['ASC']
14 * }
15 */
16
17/* Sample paging object:
18 * {
19 * limit: 3,
20 * skip: 1
21 * }
22 */
23export const myListOrdersWithFiltersFunction = webMethod(Permissions.Anyone, async (filters, sorting, paging) => {
24 try {
25 const listedOrders = await orders.listOrders(filters, sorting, paging);
26 const firstOrderId = listedOrders.orders[0]._id;
27 const firstOrderStatus = listedOrders.orders[0].status;
28
29 return listedOrders;
30 } catch (error) {
31 console.error(error);
32 }
33});
34
35/* Promise resolves to:
36 * [
37 * {
38 * "_id": "0d9c781c-d2d8-4e42-a9e6-60122ed47771",
39 * "planId": "a4d57b6c-42eb-4416-b8dd-196f1c321b78",
40 * "subscriptionId": "7b7f1800-da9a-4bf3-9e80-2eaef7e25f0c",
41 * "wixPayOrderId": "0010ea6a-a8cb-4b5d-a9fc-4ed1f337c623",
42 * "buyer": {
43 * "memberId": "fac761ea-e6f1-4e3d-8b30-a4852f091415",
44 * "contactId": "fac761ea-e6f1-4e3d-8b30-a4852f091415"
45 * },
46 * "priceDetails": {
47 * "subtotal": "33",
48 * "discount": "0",
49 * "total": "33",
50 * "planPrice": "33",
51 * "currency": "EUR",
52 * "singlePaymentForDuration": {
53 * "count": 6,
54 * "unit": "MONTH"
55 * }
56 * },
57 * "pricing": {
58 * "singlePaymentForDuration": {
59 * "count": 6,
60 * "unit": "MONTH"
61 * },
62 * "prices": [
63 * {
64 * "duration": {
65 * "cycleFrom": 1,
66 * "numberOfCycles": 1
67 * },
68 * "price": {
69 * "subtotal": "33",
70 * "discount": "0",
71 * "total": "33",
72 * "currency": "EUR"
73 * }
74 * }
75 * ]
76 * },
77 * "type": "OFFLINE",
78 * "orderMethod": "UNKNOWN",
79 * "status": "PAUSED",
80 * "lastPaymentStatus": "PAID",
81 * "startDate": "2022-06-27T13:35:22.979Z",
82 * "endDate": "2022-12-31T13:46:10.979Z",
83 * "pausePeriods": [
84 * {
85 * "status": "ENDED",
86 * "pauseDate": "2022-07-04T12:39:33.140Z",
87 * "resumeDate": "2022-07-04T12:50:21.637Z"
88 * },
89 * {
90 * "status": "ACTIVE",
91 * "pauseDate": "2022-07-04T14:22:45.006Z"
92 * }
93 * ],
94 * "earliestEndDate": "2022-12-27T13:46:11.475Z",
95 * "currentCycle": {
96 * "index": 1,
97 * "startedDate": "2022-06-27T13:35:22.979Z",
98 * "endedDate": "2022-12-31T13:46:10.979Z"
99 * },
100 * "planName": "One and Done",
101 * "planDescription": "",
102 * "planPrice": "33",
103 * "_createdDate": "2022-06-27T13:35:31.538Z",
104 * "_updatedDate": "2022-07-04T14:22:45.006Z"
105 * },
106 * {
107 * "_id": "a06b6a51-c815-44a1-a0f7-0af6cb4bbfda",
108 * "planId": "9f4ad2f3-d948-4daf-b517-eb2206b01ea1",
109 * "subscriptionId": "e2cbe3c4-322c-4530-b638-6076102e88ae",
110 * "wixPayOrderId": "b6c4a8b0-f7c1-480d-a2a9-68c5db566e16",
111 * "buyer": {
112 * "memberId": "f1654c62-53b4-43d5-b01b-acbf782dee6f",
113 * "contactId": "f1654c62-53b4-43d5-b01b-acbf782dee6f"
114 * },
115 * "priceDetails": {
116 * "subtotal": "9.99",
117 * "discount": "0",
118 * "total": "9.99",
119 * "planPrice": "9.99",
120 * "currency": "EUR",
121 * "singlePaymentUnlimited": true
122 * },
123 * "pricing": {
124 * "singlePaymentUnlimited": true,
125 * "prices": [
126 * {
127 * "duration": {
128 * "cycleFrom": 1,
129 * "numberOfCycles": 1
130 * },
131 * "price": {
132 * "subtotal": "9.99",
133 * "discount": "0",
134 * "total": "9.99",
135 * "currency": "EUR"
136 * }
137 * }
138 * ]
139 * },
140 * "type": "OFFLINE",
141 * "orderMethod": "UNKNOWN",
142 * "status": "PAUSED",
143 * "lastPaymentStatus": "PAID",
144 * "startDate": "2022-07-01T13:45:53.129Z",
145 * "pausePeriods": [
146 * {
147 * "status": "ENDED",
148 * "pauseDate": "2022-07-04T12:11:53.644Z",
149 * "resumeDate": "2022-07-04T12:37:33.089Z"
150 * },
151 * {
152 * "status": "ACTIVE",
153 * "pauseDate": "2022-07-10T09:57:23.919Z"
154 * }
155 * ],
156 * "currentCycle": {
157 * "index": 1,
158 * "startedDate": "2022-07-01T13:45:53.129Z"
159 * },
160 * "planName": "Gold",
161 * "planDescription": "Gold membership to the MyGame World of Online Gaming",
162 * "planPrice": "9.99",
163 * "_createdDate": "2022-07-04T11:21:14.790Z",
164 * "_updatedDate": "2022-07-10T09:57:23.919Z"
165 * },
166 * {
167 * "_id": "00739d76-edc0-4ce4-ab20-172bf09dd2f0",
168 * "planId": "9f4ad2f3-d948-4daf-b517-eb2206b01ea1",
169 * "subscriptionId": "2de691a9-7833-48e8-a3e0-3912d9896069",
170 * "wixPayOrderId": "b1204e93-ac5a-4116-9ad8-52e44017125a",
171 * "buyer": {
172 * "memberId": "f1654c62-53b4-43d5-b01b-acbf782dee6f",
173 * "contactId": "f1654c62-53b4-43d5-b01b-acbf782dee6f"
174 * },
175 * "priceDetails": {
176 * "subtotal": "9.99",
177 * "discount": "0",
178 * "total": "9.99",
179 * "planPrice": "9.99",
180 * "currency": "EUR",
181 * "singlePaymentUnlimited": true
182 * },
183 * "pricing": {
184 * "singlePaymentUnlimited": true,
185 * "prices": [
186 * {
187 * "duration": {
188 * "cycleFrom": 1,
189 * "numberOfCycles": 1
190 * },
191 * "price": {
192 * "subtotal": "9.99",
193 * "discount": "0",
194 * "total": "9.99",
195 * "currency": "EUR"
196 * }
197 * }
198 * ]
199 * },
200 * "type": "OFFLINE",
201 * "orderMethod": "UNKNOWN",
202 * "status": "PAUSED",
203 * "lastPaymentStatus": "PAID",
204 * "startDate": "2022-07-11T13:45:53.129Z",
205 * "pausePeriods": [
206 * {
207 * "status": "ACTIVE",
208 * "pauseDate": "2022-07-12T15:07:41.283Z"
209 * }
210 * ],
211 * "currentCycle": {
212 * "index": 1,
213 * "startedDate": "2022-07-11T13:45:53.129Z"
214 * },
215 * "planName": "Gold",
216 * "planDescription": "Gold membership to the MyGame World of Online Gaming",
217 * "planPrice": "9.99",
218 * "_createdDate": "2022-07-04T14:18:46.636Z",
219 * "_updatedDate": "2022-07-12T15:07:41.283Z"
220 * }
221 * ]
222 */
Iterate through all pages of orders

This example demonstrates how to retrieve all orders, bypassing the maximum limit of 50.

Copy Code
1import { Permissions, webMethod } from 'wix-web-module';
2import { orders } from 'wix-pricing-plans-backend';
3
4// Retrieve all orders
5
6export const myListAllOrdersFunction = webMethod(Permissions.Anyone, async () => {
7 const ordersPerPage = 50;
8
9 let pageNumber = 0;
10 let currentOrdersPage = [];
11 let allOrders = [];
12
13 do {
14 let ordersToSkip = { skip: pageNumber * ordersPerPage };
15 try {
16 currentOrdersPage = await orders.listOrders(null, null, ordersToSkip);
17 } catch (error) {
18 console.error(error);
19 }
20 allOrders = allOrders.concat(currentOrdersPage);
21 pageNumber++;
22 } while (currentOrdersPage.length != 0)
23
24 return allOrders;
25});