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 totrue
.
Syntax
function listOrders([filters: FilterOptions], [sorting: SortingOptions], [paging: PaginationOptions], [options: Options]): Promise<Array<Order>>
listOrders Parameters
NAME
TYPE
DESCRIPTION
Filter options for limiting which orders are listed.
Sorting options, such as by which property and in which direction.
Pagination options, such as how many results are listed at a time.
Options to use when listing orders.
Returns
Fulfilled - Pricing plan orders that match the specified filtering, sorting, and pagination options.
Return Type:
NAME
TYPE
DESCRIPTION
Order ID.
ID of the plan that was ordered.
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.
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.
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
.
Deprecated. Use pricing
instead.
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 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.
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.
Details about the cancellation of an order. Only present if the status
is "CANCELED"
.
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.
Start date and time for the ordered plan.
List of periods during which this order is paused.
Free trial period, in days. Only available for recurring plans.
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.
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.
Name of the plan at the time of the order.
Description of the plan at the time of the order.
Plan price as it was at the moment of order creation.
Date and time the order was created.
Date and time the order was last updated. For example, the date and time an order was paused, resumed, or canceled.
Related Content:
Was this helpful?
1import { orders } from 'wix-pricing-plans-backend';23export async function myListOrdersFunction() {45 try {6 const listedOrders = await orders.listOrders();78 return listedOrders;9 } catch (error) {10 console.error(error);11 }12}1314// Promise resolves to an array of order objects.
1import { orders } from 'wix-pricing-plans-backend';23// Sample options object: { suppressAuth : true }45export async function myListOrdersWithOptionsFunction(options) {6 try {7 const listedOrders = await orders.listOrders(null, null, null, options);8 const firstOrderId = listedOrders.orders[0]._id;9 const firstOrderStatus = listedOrders.orders[0].status;1011 return listedOrders;12 } catch (error) {13 console.error(error);14 }15}1617/* Promise resolves to an array of order objects--even if you do not have a role with18 * permissions for listing orders.19 */
1import { orders } from 'wix-pricing-plans-backend';23/* Sample filters object:4 * {5 * orderStatuses: ['PAUSED', 'CANCELED']6 * }7 */89/* Sample sorting object:10 * {11 * fieldName: ['createdDate'],12 * order: ['ASC']13 * }14 */1516/* Sample paging object:17 * {18 * limit: 3,19 * skip: 120 * }21 */2223export async function myListOrdersWithFiltersFunction(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;2829 return listedOrders;30 } catch (error) {31 console.error(error);32 }33}3435/* 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": 167 * },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": true122 * },123 * "pricing": {124 * "singlePaymentUnlimited": true,125 * "prices": [126 * {127 * "duration": {128 * "cycleFrom": 1,129 * "numberOfCycles": 1130 * },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": true182 * },183 * "pricing": {184 * "singlePaymentUnlimited": true,185 * "prices": [186 * {187 * "duration": {188 * "cycleFrom": 1,189 * "numberOfCycles": 1190 * },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 */
This example demonstrates how to retrieve all orders, bypassing the maximum limit of 50.
1import { orders } from 'wix-pricing-plans-backend';23// Retrieve all orders45export async function myListAllOrdersFunction() {67 const ordersPerPage = 50;89 let pageNumber = 0;10 let currentOrdersPage = [];11 let allOrders = [];1213 // Use the 'skip' parameter to retrieve sequential pages of 50 orders14 // until the retrieved page contains no orders15 do {16 let ordersToSkip = {skip: pageNumber * ordersPerPage};17 try {18 currentOrdersPage = await orders.listOrders(null, null, ordersToSkip);19 } catch (error) {20 console.error(error);21 }22 allOrders = allOrders.concat(currentOrdersPage);23 pageNumber++;24 } while (currentOrdersPage.length != 0)2526 return allOrders;27}28