memberListOrders( )
Lists orders for the currently logged-in member.
Description
The memberListOrders()
function returns a Promise that resolves to a list of up to 100 pricing plan orders.
Syntax
function memberListOrders(options: MemberListOrdersOptions): Promise<MemberListOrdersResponse>
memberListOrders Parameters
NAME
TYPE
DESCRIPTION
Filtering, sorting, and pagination options.
Returns
Return Type:
NAME
TYPE
DESCRIPTION
List of orders.
Object containing paging-related data (number of orders returned, offset).
Was this helpful?
1import { orders } from 'wix-pricing-plans.v2';23export async function myMemberListOrdersFunction() {4 try {5 const ordersList = await orders.memberListOrders();67 return ordersList;8 } catch (error) {9 console.error(error);10 // Handle the error11 }12}1314/* Promise resolves to:15 * {16 * "orders": [17 * {18 * "planPrice": "0",19 * "_id": "292c6b6b-81ec-4c10-b067-78b1a1b2fada",20 * "_createdDate": "2024-02-05T17:26:23.348Z",21 * "subscriptionId": "973e0e0b-85c2-4d2b-9693-fc8f1140d958",22 * "pausePeriods": [],23 * "_updatedDate": "2024-02-05T17:26:24.129Z",24 * "planName": "Free Plan",25 * "buyer": {26 * "memberId": "695568ff-1dc2-49ff-83db-2b518d35692b",27 * "contactId": "695568ff-1dc2-49ff-83db-2b518d35692b"28 * },29 * "lastPaymentStatus": "NOT_APPLICABLE",30 * "status": "ACTIVE",31 * "orderMethod": "UNKNOWN",32 * "planDescription": "",33 * "formData": {34 * "formId": "ee62cefa-bdc2-4b5d-baab-6faeef83cecb",35 * "submissionId": "6d68798b-b5ea-4471-b029-dea6e4ac043a",36 * "submissionData": {}37 * },38 * "statusNew": "ACTIVE",39 * "cycles": [40 * {41 * "index": 1,42 * "startedDate": "2024-02-05T17:26:23.348Z"43 * }44 * ],45 * "type": "ONLINE",46 * "planId": "3a3e0ac2-a9e3-4bfd-ade3-bec3bab34d4b",47 * "startDate": "2024-02-05T17:26:23.348Z",48 * "currentCycle": {49 * "index": 1,50 * "startedDate": "2024-02-05T17:26:23.348Z"51 * },52 * "pricing": {53 * "singlePaymentUnlimited": true,54 * "prices": [55 * {56 * "duration": {57 * "cycleFrom": 1,58 * "numberOfCycles": 159 * },60 * "price": {61 * "tax": {62 * "name": "Tax",63 * "includedInPrice": false,64 * "rate": "6.5",65 * "amount": "0"66 * },67 * "total": "0",68 * "proration": "0",69 * "fees": [],70 * "currency": "USD",71 * "subtotal": "0.00",72 * "discount": "0"73 * }74 * }75 * ]76 * },77 * "priceDetails": {78 * "planPrice": "0",79 * "tax": {80 * "name": "Tax",81 * "includedInPrice": false,82 * "rate": "6.5",83 * "amount": "0"84 * },85 * "total": "0",86 * "currency": "USD",87 * "subtotal": "0.00",88 * "discount": "0",89 * "singlePaymentUnlimited": true90 * }91 * },92 * {93 * "planPrice": "0",94 * "_id": "7b4ec42c-582a-4e2f-874b-09e66e0ae09d",95 * "_createdDate": "2024-01-28T08:35:15.230Z",96 * "subscriptionId": "08bc02c5-7663-4578-948a-ff23370e07e5",97 * "pausePeriods": [],98 * "_updatedDate": "2024-01-28T08:35:16.080Z",99 * "planName": "Standard Plan",100 * "buyer": {101 * "memberId": "695568ff-1dc2-49ff-83db-2b518d35692b",102 * "contactId": "695568ff-1dc2-49ff-83db-2b518d35692b"103 * },104 * "lastPaymentStatus": "NOT_APPLICABLE",105 * "status": "ACTIVE",106 * "orderMethod": "UNKNOWN",107 * "planDescription": "Full functionality for new users",108 * "formData": {109 * "formId": "3ef36359-24bd-471a-aa8b-a5ca683b50f4",110 * "submissionId": "2cf62c7a-d3ed-4dd9-816d-01919aaf2170",111 * "submissionData": {}112 * },113 * "statusNew": "ACTIVE",114 * "cycles": [115 * {116 * "index": 1,117 * "startedDate": "2024-01-28T08:35:15.230Z"118 * }119 * ],120 * "type": "ONLINE",121 * "planId": "df83348a-777d-46ab-8d62-a43c415bdb11",122 * "startDate": "2024-01-28T08:35:15.230Z",123 * "currentCycle": {124 * "index": 1,125 * "startedDate": "2024-01-28T08:35:15.230Z"126 * },127 * "pricing": {128 * "singlePaymentUnlimited": true,129 * "prices": [130 * {131 * "duration": {132 * "cycleFrom": 1,133 * "numberOfCycles": 1134 * },135 * "price": {136 * "total": "0",137 * "proration": "0",138 * "fees": [],139 * "currency": "USD",140 * "subtotal": "0.00",141 * "discount": "0"142 * }143 * }144 * ]145 * },146 * "priceDetails": {147 * "planPrice": "0",148 * "total": "0",149 * "currency": "USD",150 * "subtotal": "0.00",151 * "discount": "0",152 * "singlePaymentUnlimited": true153 * }154 * }155 * ]156 * }157 */
1import { Permissions, webMethod } from 'wix-web-module';2import { orders } from 'wix-pricing-plans.v2';34export const myMemberListOrdersFunction = webMethod(Permissions.Anyone, async () => {5 try {6 const ordersList = await orders.memberListOrders();78 return ordersList;9 } catch (error) {10 console.error(error);11 // Handle the error12 }13});1415/* Promise resolves to:16 * {17 * "orders": [18 * {19 * "planPrice": "0",20 * "_id": "292c6b6b-81ec-4c10-b067-78b1a1b2fada",21 * "_createdDate": "2024-02-05T17:26:23.348Z",22 * "subscriptionId": "973e0e0b-85c2-4d2b-9693-fc8f1140d958",23 * "pausePeriods": [],24 * "_updatedDate": "2024-02-05T17:26:24.129Z",25 * "planName": "Free Plan",26 * "buyer": {27 * "memberId": "695568ff-1dc2-49ff-83db-2b518d35692b",28 * "contactId": "695568ff-1dc2-49ff-83db-2b518d35692b"29 * },30 * "lastPaymentStatus": "NOT_APPLICABLE",31 * "status": "ACTIVE",32 * "orderMethod": "UNKNOWN",33 * "planDescription": "",34 * "formData": {35 * "formId": "ee62cefa-bdc2-4b5d-baab-6faeef83cecb",36 * "submissionId": "6d68798b-b5ea-4471-b029-dea6e4ac043a",37 * "submissionData": {}38 * },39 * "statusNew": "ACTIVE",40 * "cycles": [41 * {42 * "index": 1,43 * "startedDate": "2024-02-05T17:26:23.348Z"44 * }45 * ],46 * "type": "ONLINE",47 * "planId": "3a3e0ac2-a9e3-4bfd-ade3-bec3bab34d4b",48 * "startDate": "2024-02-05T17:26:23.348Z",49 * "currentCycle": {50 * "index": 1,51 * "startedDate": "2024-02-05T17:26:23.348Z"52 * },53 * "pricing": {54 * "singlePaymentUnlimited": true,55 * "prices": [56 * {57 * "duration": {58 * "cycleFrom": 1,59 * "numberOfCycles": 160 * },61 * "price": {62 * "tax": {63 * "name": "Tax",64 * "includedInPrice": false,65 * "rate": "6.5",66 * "amount": "0"67 * },68 * "total": "0",69 * "proration": "0",70 * "fees": [],71 * "currency": "USD",72 * "subtotal": "0.00",73 * "discount": "0"74 * }75 * }76 * ]77 * },78 * "priceDetails": {79 * "planPrice": "0",80 * "tax": {81 * "name": "Tax",82 * "includedInPrice": false,83 * "rate": "6.5",84 * "amount": "0"85 * },86 * "total": "0",87 * "currency": "USD",88 * "subtotal": "0.00",89 * "discount": "0",90 * "singlePaymentUnlimited": true91 * }92 * },93 * {94 * "planPrice": "0",95 * "_id": "7b4ec42c-582a-4e2f-874b-09e66e0ae09d",96 * "_createdDate": "2024-01-28T08:35:15.230Z",97 * "subscriptionId": "08bc02c5-7663-4578-948a-ff23370e07e5",98 * "pausePeriods": [],99 * "_updatedDate": "2024-01-28T08:35:16.080Z",100 * "planName": "Standard Plan",101 * "buyer": {102 * "memberId": "695568ff-1dc2-49ff-83db-2b518d35692b",103 * "contactId": "695568ff-1dc2-49ff-83db-2b518d35692b"104 * },105 * "lastPaymentStatus": "NOT_APPLICABLE",106 * "status": "ACTIVE",107 * "orderMethod": "UNKNOWN",108 * "planDescription": "Full functionality for new users",109 * "formData": {110 * "formId": "3ef36359-24bd-471a-aa8b-a5ca683b50f4",111 * "submissionId": "2cf62c7a-d3ed-4dd9-816d-01919aaf2170",112 * "submissionData": {}113 * },114 * "statusNew": "ACTIVE",115 * "cycles": [116 * {117 * "index": 1,118 * "startedDate": "2024-01-28T08:35:15.230Z"119 * }120 * ],121 * "type": "ONLINE",122 * "planId": "df83348a-777d-46ab-8d62-a43c415bdb11",123 * "startDate": "2024-01-28T08:35:15.230Z",124 * "currentCycle": {125 * "index": 1,126 * "startedDate": "2024-01-28T08:35:15.230Z"127 * },128 * "pricing": {129 * "singlePaymentUnlimited": true,130 * "prices": [131 * {132 * "duration": {133 * "cycleFrom": 1,134 * "numberOfCycles": 1135 * },136 * "price": {137 * "total": "0",138 * "proration": "0",139 * "fees": [],140 * "currency": "USD",141 * "subtotal": "0.00",142 * "discount": "0"143 * }144 * }145 * ]146 * },147 * "priceDetails": {148 * "planPrice": "0",149 * "total": "0",150 * "currency": "USD",151 * "subtotal": "0.00",152 * "discount": "0",153 * "singlePaymentUnlimited": true154 * }155 * }156 * ]157 * }158 */159
This example provides a dropdown list of active orders for a logged-in member. The member selects a plan from the #ordersDropdown
and clicks the #cancelOrderBtn
to cancel the plan or the #pauseOrderBtn
to pause the plan.
1/*******************************2 * Backend code - order.web.js *3********************************/45import { Permissions, webMethod } from 'wix-web-module';6import { orders } from 'wix-pricing-plans.v2';7import { elevate } from 'wix-auth';89const elevatedPauseOrder = elevate(orders.pauseOrder);1011export const listCurrentMemberOrders = webMethod(12 Permissions.Anyone,13 async (orderStatuses) => {14 try {15 const result = await orders.memberListOrders(orderStatuses);1617 return result;18 } catch (error) {19 console.error(error);20 // Handle the error21 }22 });2324export const requestCancellation = webMethod(25 Permissions.Anyone,26 async (orderId) => {27 const effectiveAt = 'NEXT_PAYMENT_DATE';28 try {29 await orders.requestCancellation(orderId, effectiveAt) ;3031 return;32 } catch (error) {33 console.error(error);34 // Handle the error35 }36 });3738export const pauseOrder = webMethod(39 Permissions.Anyone,40 async (orderId) => {41 try {42 await elevatedPauseOrder(orderId);4344 return;45 } catch (error) {46 console.error(error);47 // Handle the error48 }49 });5051/*************52 * Page code *53 *************/5455import { listCurrentMemberOrders, requestCancellation, pauseOrder } from 'backend/order.web';5657$w.onReady(function () {58 // Disabe UI elements on page load59 $w('#requestCancelOrderBtn').disable();60 $w('#pauseOrderBtn').disable();61 $w('#ordersDropdown').disable();6263 let selectedOrderId;64 populateOrdersDropdown();6566 $w('#ordersDropdown').onChange( () => {67 selectedOrderId = $w('#ordersDropdown').value;68 $w('#requestCancelOrderBtn').enable();69 $w('#pauseOrderBtn').enable();70 });7172 $w('#requestCancelOrderBtn').onClick(async () => {73 await requestCancellation(selectedOrderId);74 });7576 $w('#pauseOrderBtn').onClick(async () => {77 await pauseOrder(selectedOrderId);78 });79});8081async function populateOrdersDropdown() {82 const activeOrdersList = await listCurrentMemberOrders({orderStatuses: 'ACTIVE'});83 $w('#ordersDropdown').options = activeOrdersList.orders.map((order) => {84 return {85 label: order.planName,86 value: order._id87 }88 });89 $w('#ordersDropdown').enable();90}
Page code provides button list of active orders for a logged-in member. Member selects paused plan and submits #resumeOrderBtn
to resume the order. #orderSelection
and resumeOrderBtn
are initially disabled.
1/*******************************2 * Backend code - order.web.js *3 *******************************/45import { Permissions, webMethod } from 'wix-web-module';6import { orders } from 'wix-pricing-plans.v2';7import { elevate } from 'wix-auth';89const elevatedResumeOrder = elevate(orders.resumeOrder);1011export const getPausedMemberOrders = webMethod(12 Permissions.Anyone,13 async () => {14 try {15 const options = {16 orderStatuses: 'PAUSED'17 };18 const result = await orders.memberListOrders(options);19 const getPausedMemberOrders = result.orders;2021 return result;22 } catch (error) {23 console.error(error);24 // Handle the error25 }26 });2728export const resumeOrder = webMethod(29 Permissions.Anyone,30 async (orderId) => {31 try {32 await elevatedResumeOrder(orderId);3334 return;35 } catch (error) {36 console.error(error);37 // Handle the error38 }39 });4041/*************42 * Page code *43 *************/4445import { getPausedMemberOrders, resumeOrder } from 'backend/order.web';4647$w.onReady(function () {48 let selectedOrderId;49 populateOrderButtonList();5051 $w('#orderSelection').onChange(() => {52 selectedOrderId = $w('#orderSelection').value;53 $w('#resumeOrderBtn').enable();54 });5556 $w('#resumeOrderBtn').onClick(async () => {57 await resumeOrder(selectedOrderId);58 });5960});6162async function populateOrderButtonList() {63 const pausedOrders = await getPausedMemberOrders();64 $w('#pausedOrders').options = pausedOrders.map(item => {65 return {66 label: item.planName,67 value: item._id68 }69 });7071 $w('#pausedOrders').show();72}