Search...
resumeOrder( )
Developer Preview
Resumes a paused pricing plan order.
Description
The resumeOrder()
function returns a Promise that resolves when a paused order is successfully resumed.
For orders with recurring payments, resumeOrder()
also restarts the payment schedule.
Resuming an order causes the following changes:
- The order status changes to
"ACTIVE"
. - The
pausePeriods
array is updated. - The
endDate
for the order is adjusted to include the pause period. - The
earliestEndDate
is adjusted to include the pause period. (This property is reserved for future use).
Admin Method
This function requires elevated permissions to run. This function is not universal and runs only on the backend.
Syntax
function resumeOrder(_id: string): Promise<void>
resumeOrder Parameters
NAME
TYPE
DESCRIPTION
_id
string
Order ID.
Returns
Fulfilled - When the order is resumed.
Return Type:
Promise<
void
>Was this helpful?
Resume an order (dashboard page code)
Copy Code
1import { orders } from 'wix-pricing-plans.v2';2import { elevate } from 'wix-auth';34/* Sample _id value: '9af3cbe6-fe27-4fdb-a0b0-892289b03d22' */56const elevatedResumeOrder = elevate(orders.resumeOrder);78export async function myResumeOrderFunction(_id) {9 try {10 await elevatedResumeOrder(_id);1112 return;13 } catch (error) {14 console.error(error);15 // Handle the error16 }17}1819/* Promise resolves to void */
Resume an order (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';45// Sample _id value: '9af3cbe6-fe27-4fdb-a0b0-892289b03d22'67const elevatedResumeOrder = elevate(orders.resumeOrder);89export const myResumeOrderFunction = webMethod(Permissions.Anyone, async (_id) => {10 try {11 await elevatedResumeOrder(_id);1213 return;14 } catch (error) {15 console.error(error);16 // Handle the error17 }18});1920/* Promise resolves to void */21
Resume paused orders by a member
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.
Copy Code
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}