Search.../

managementListOrders( )

Developer Preview

Lists pricing plan orders.

Description

The managementListOrders() 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 currently logged-in member, use memberListOrders().

Admin Method

This function requires elevated permissions to run. This function is not universal and runs only on the backend.

Syntax

function managementListOrders(options: ManagementListOrdersOptions): Promise<ListOrdersResponse>

managementListOrders Parameters

NAME
TYPE
DESCRIPTION
options
Optional
ManagementListOrdersOptions

Filtering, sorting, and pagination options.

Returns

Return Type:

Promise<
ListOrdersResponse
>
NAME
TYPE
DESCRIPTION
orders
Array<
Order
>

List of orders.

pagingMetadata
PagingMetadataV2

Object containing paging-related data (number of orders returned, offset).

Was this helpful?

List pricing plan orders (dashboard page code)

Copy Code
1import { orders } from 'wix-pricing-plans.v2';
2import { elevate } from 'wix-auth';
3
4const elevatedManagementListOrders = elevate(orders.managementListOrders);
5
6export async function myManagementListOrdersFunction() {
7 try {
8 const ordersList = await elevatedManagementListOrders();
9
10 return ordersList;
11 } catch (error){
12 console.error(error);
13 // Handle the error
14 }
15}
16
17/* Promise resolves to:
18 * {
19 * "orders": [
20 * {
21 * "_createdDate": "2024-01-22T14:00:53.904Z",
22 * "_id": "14fac8ae-506e-4e7b-84d4-e9b094d0ddca",
23 * "_updatedDate": "2024-01-22T14:00:54.772Z",
24 * "buyer": {
25 * "contactId": "f5691fc2-0674-4eee-92c5-da06a05981a5",
26 * "memberId": "f5691fc2-0674-4eee-92c5-da06a05981a5"
27 * },
28 * "currentCycle": {
29 * "index": 1,
30 * "startedDate": "2024-01-22T14:00:53.904Z"
31 * },
32 * "cycles": [
33 * {
34 * "index": 1,
35 * "startedDate": "2024-01-22T14:00:53.904Z"
36 * }
37 * ],
38 * "formData": {
39 * "submissionData": {}
40 * },
41 * "lastPaymentStatus": "NOT_APPLICABLE",
42 * "orderMethod": "UNKNOWN",
43 * "pausePeriods": [],
44 * "planDescription": "",
45 * "planId": "aa0d8e0e-99ad-4c95-ac48-4955e37956c5",
46 * "planName": "Default",
47 * "planPrice": "0",
48 * "priceDetails": {
49 * "currency": "EUR",
50 * "discount": "0",
51 * "planPrice": "0",
52 * "singlePaymentUnlimited": true,
53 * "subtotal": "0.00",
54 * "total": "0"
55 * },
56 * "pricing": {
57 * "prices": [
58 * {
59 * "duration": {
60 * "cycleFrom": 1,
61 * "numberOfCycles": 1
62 * },
63 * "price": {
64 * "currency": "EUR",
65 * "discount": "0",
66 * "fees": [],
67 * "proration": "0",
68 * "subtotal": "0.00",
69 * "total": "0"
70 * }
71 * }
72 * ],
73 * "singlePaymentUnlimited": true
74 * },
75 * "priceDetails": {
76 * "currency": "EUR",
77 * "discount": "0",
78 * "planPrice": "0",
79 * "singlePaymentUnlimited": true,
80 * "subtotal": "0.00",
81 * "total": "0"
82 * },
83 * "startDate": "2024-01-22T14:00:53.904Z",
84 * "status": "ACTIVE",
85 * "statusNew": "ACTIVE",
86 * "subscriptionId": "19276032-d06f-4931-962f-79486d8b6bc0",
87 * "type": "ONLINE"
88 * }
89 * ],
90 * "pagingMetadata": {
91 * "count": 1,
92 * "hasNext": false,
93 * "offset": 0,
94 * "total": 1
95 * }
96 * }
97 */
List pricing plan orders (export from backend code)

Copy Code
1import { Permissions, webMethod } from 'wix-web-module';
2import { orders } from 'wix-pricing-plans.v2';
3import { elevate } from 'wix-auth';
4
5const elevatedManagementListOrders = elevate(orders.managementListOrders);
6
7export const myManagementListOrdersFunction = webMethod(Permissions.Anyone, async () => {
8 try {
9 const ordersList = await elevatedManagementListOrders();
10
11 return ordersList;
12 } catch (error){
13 console.error(error);
14 // Handle the error
15 }
16});
17
18/* Promise resolves to:
19 * {
20 * "orders": [
21 * {
22 * "_createdDate": "2024-01-22T14:00:53.904Z",
23 * "_id": "14fac8ae-506e-4e7b-84d4-e9b094d0ddca",
24 * "_updatedDate": "2024-01-22T14:00:54.772Z",
25 * "buyer": {
26 * "contactId": "f5691fc2-0674-4eee-92c5-da06a05981a5",
27 * "memberId": "f5691fc2-0674-4eee-92c5-da06a05981a5"
28 * },
29 * "currentCycle": {
30 * "index": 1,
31 * "startedDate": "2024-01-22T14:00:53.904Z"
32 * },
33 * "cycles": [
34 * {
35 * "index": 1,
36 * "startedDate": "2024-01-22T14:00:53.904Z"
37 * }
38 * ],
39 * "formData": {
40 * "submissionData": {}
41 * },
42 * "lastPaymentStatus": "NOT_APPLICABLE",
43 * "orderMethod": "UNKNOWN",
44 * "pausePeriods": [],
45 * "planDescription": "",
46 * "planId": "aa0d8e0e-99ad-4c95-ac48-4955e37956c5",
47 * "planName": "Default",
48 * "planPrice": "0",
49 * "priceDetails": {
50 * "currency": "EUR",
51 * "discount": "0",
52 * "planPrice": "0",
53 * "singlePaymentUnlimited": true,
54 * "subtotal": "0.00",
55 * "total": "0"
56 * },
57 * "pricing": {
58 * "prices": [
59 * {
60 * "duration": {
61 * "cycleFrom": 1,
62 * "numberOfCycles": 1
63 * },
64 * "price": {
65 * "currency": "EUR",
66 * "discount": "0",
67 * "fees": [],
68 * "proration": "0",
69 * "subtotal": "0.00",
70 * "total": "0"
71 * }
72 * }
73 * ],
74 * "singlePaymentUnlimited": true
75 * },
76 * "priceDetails": {
77 * "currency": "EUR",
78 * "discount": "0",
79 * "planPrice": "0",
80 * "singlePaymentUnlimited": true,
81 * "subtotal": "0.00",
82 * "total": "0"
83 * },
84 * "startDate": "2024-01-22T14:00:53.904Z",
85 * "status": "ACTIVE",
86 * "statusNew": "ACTIVE",
87 * "subscriptionId": "19276032-d06f-4931-962f-79486d8b6bc0",
88 * "type": "ONLINE"
89 * }
90 * ],
91 * "pagingMetadata": {
92 * "count": 1,
93 * "hasNext": false,
94 * "offset": 0,
95 * "total": 1
96 * }
97 * }
98 */
99
List pricing plan orders with options

Copy Code
1import { Permissions, webMethod } from 'wix-web-module';
2import { orders } from 'wix-pricing-plans.v2';
3import { elevate } from 'wix-auth';
4
5/* Sample options value:
6 * {
7 * autoRenewCanceled: false,
8 * buyerIds: [
9 * '402ec90c-235a-45c4-b4cc-52204d5f6b00',
10 * '3fc889f6-18e8-4fd9-a509-27db9f037f26',
11 * 'fa16f1dc-0fbd-41c0-8efc-53333e3fce1e',
12 * '554c9e11-f4d8-4579-ac3a-a17f7e6cb0b4',
13 * '695568ff-1dc2-49ff-83db-2b518d35692b',
14 * '554c9e11-f4d8-4579-ac3a-a17f7e6cb0b4',
15 * 'f5691fc2-0674-4eee-92c5-da06a05981a5'
16 * ],
17 * fieldSet: 'BASIC',
18 * limit: 3,
19 * offset: 0,
20 * orderStatuses: [
21 * 'ACTIVE'
22 * ],
23 * paymentStatus: [
24 * 'PAID',
25 * 'NOT_APPLICABLE'
26 * ],
27 * planIds: [
28 * '0da57ac8-c3d0-4687-8aea-4100781b6386',
29 * 'df83348a-777d-46ab-8d62-a43c415bdb11',
30 * '3a3e0ac2-a9e3-4bfd-ade3-bec3bab34d4b',
31 * 'cb4a8c57-273a-4567-94e3-cc43d5d339f2',
32 * 'df83348a-777d-46ab-8d62-a43c415bdb11',
33 * 'aa0d8e0e-99ad-4c95-ac48-4955e37956c5',
34 * 'aa0d8e0e-99ad-4c95-ac48-4955e37956c5'
35 * ],
36 * sorting: {
37 * fieldName: 'createdDate',
38 * order: 'ASC'
39 * };
40 */
41
42const elevatedManagementListOrders = elevate(orders.managementListOrders);
43
44export const myManagementListOrdersFunction = webMethod(Permissions.Anyone, async (options) => {
45 try {
46 const ordersList = await elevatedManagementListOrders(options);
47
48 return ordersList;
49 } catch (error) {
50 console.error(error);
51 // Handle the error
52 }
53});
54
55/* Promise resolves to:
56 * {
57 * "orders": [
58 * {
59 * "_createdDate": "2024-01-28T09:49:21.041Z",
60 * "_id": "82d99338-5653-459a-a751-b57483f7cfb5",
61 * "_updatedDate": "2024-02-04T10:42:58.888Z",
62 * "autoRenewCanceled": false,
63 * "buyer": {
64 * "contactId": "554c9e11-f4d8-4579-ac3a-a17f7e6cb0b4",
65 * "memberId": "554c9e11-f4d8-4579-ac3a-a17f7e6cb0b4"
66 * },
67 * "currentCycle": {
68 * "endedDate": "2024-04-27T09:49:21.041Z",
69 * "index": 0,
70 * "startedDate": "2024-01-28T09:49:21.041Z"
71 * },
72 * "cycles": [
73 * {
74 * "endedDate": "2024-04-27T09:49:21.041Z",
75 * "index": 0,
76 * "startedDate": "2024-01-28T09:49:21.041Z"
77 * }
78 * ],
79 * "endDate": "2026-07-29T09:49:21.041Z",
80 * "earliestEndDate": "2026-04-27T09:49:21.041Z",
81 * "formData": {
82 * "submissionData": {}
83 * },
84 * "freeTrialDays": 90,
85 * "lastPaymentStatus": "PAID",
86 * "orderMethod": "UNKNOWN",
87 * "pausePeriods": [],
88 * "planDescription": "3 mo free trial with discount for 1 year",
89 * "planId": "cb4a8c57-273a-4567-94e3-cc43d5d339f2",
90 * "planName": "Beginner's Plan",
91 * "planPrice": "50",
92 * "priceDetails": {
93 * "currency": "USD",
94 * "discount": "0",
95 * "freeTrialDays": 90,
96 * "planPrice": "50",
97 * "subtotal": "50.00",
98 * "total": "50.00"
99 * },
100 * "pricing": {
101 * "prices": [
102 * {
103 * "duration": {
104 * "cycleFrom": 1,
105 * "numberOfCycles": 2
106 * },
107 * "price": {
108 * "currency": "USD",
109 * "discount": "0",
110 * "fees": [],
111 * "proration": "0",
112 * "subtotal": "50.00",
113 * "total": "50.00"
114 * }
115 * }
116 * ],
117 * "singlePaymentUnlimited": true
118 * },
119 * "startDate": "2024-01-28T09:49:21.041Z",
120 * "status": "ACTIVE",
121 * "statusNew": "ACTIVE",
122 * "subscriptionId": "305f8fc9-3724-4cac-9f67-4e29f2c46def",
123 * "type": "OFFLINE",
124 * "wixPayOrderId": "2f0e79d8-f15d-46c6-ac1a-10ec7a2030fb"
125 * }
126 * ],
127 * "pagingMetadata": {
128 * "count": 1,
129 * "hasNext": false,
130 * "offset": 0,
131 * "total": 1
132 * }
133 * }
134 */
135
136
Manager cancellation or updated payment status of multiple orders

In this example, the page code provides a checkable list of unpaid customer orders. The site owner or admin selects the unpaid orders to be cancelled or updated to a PAID payment status.

Copy Code
1/*******************************
2 * Backend code - utils.web.js *
3 *******************************/
4
5import { Permissions, webMethod } from 'wix-web-module';
6import { orders } from 'wix-pricing-plans.v2';
7import { elevate } from 'wix-auth';
8
9const elevatedManagementListOrders = elevate(orders.managementListOrders);
10const elevatedCancelOrder = elevate(orders.cancelOrder);
11const elevatedMarkAsPaid = elevate(orders.markAsPaid);
12
13export const getUnpaidOrders = webMethod(
14 Permissions.Anyone,
15 async () => {
16 const options = { paymentStatuses: 'UNPAID' };
17 try {
18 const ordersList = await elevatedManagementListOrders(options);
19
20 return ordersList;
21 } catch (error) {
22 console.error(error);
23 // Handle the error
24 }
25 });
26
27export const cancelOrder = webMethod(
28 Permissions.Anyone,
29 async (orderId) => {
30 const effectiveAt = 'NEXT_PAYMENT_DATE';
31 try {
32 await elevatedCancelOrder(orderId, effectiveAt);
33
34 return;
35 } catch (error) {
36 console.error(error);
37 // Handle the error
38 }
39 });
40
41export const markAsPaid = webMethod(
42 Permissions.Anyone,
43 async (orderId) => {
44 try {
45 await elevatedMarkAsPaid(orderId);
46
47 return;
48 } catch (error) {
49 console.error(error);
50 // Handle the error
51 }
52 });
53
54/*************
55 * Page code *
56 *************/
57
58import { getUnpaidOrders, cancelOrder, markAsPaid } from 'backend/utils.web';
59
60$w.onReady(function () {
61 $w('#ordersCheckbox').hide();
62 $w('#markAsPaidBtn').disable();
63 $w('#cancelOrderBtn').disable();
64
65
66 populateOrdersCheckbox();
67 let orderValues;
68
69 $w('#ordersCheckbox').onChange(() => {
70 orderValues = $w('#ordersCheckbox').value;
71 });
72
73 // Cancel multiple orders
74 $w('#cancelOrderBtn').onClick(() => {
75 orderValues.forEach(async (orderId) => {
76 await cancelOrder(orderId);
77 });
78 });
79
80 // Mark multiple orders as paid
81 $w('#markAsPaidBtn').onClick(() => {
82 orderValues.forEach(async (orderId) => {
83 await markAsPaid(orderId);
84 });
85 });
86});
87
88async function populateOrdersCheckbox() {
89 const unpaidOrders = await getUnpaidOrders();
90
91 // Displays each order with its corresponding member ID
92 $w('#ordersCheckbox').options = unpaidOrders.orders.map(item => {
93 return {
94 label: `${item.planName} - memberId: ${item.buyer.memberId}`,
95 value: item._id
96 }
97 });
98 $w('#ordersCheckbox').show();
99 $w('#markAsPaidBtn').enable();
100 $w('#cancelOrderBtn').enable();
101}