pauseOrder( )
Pauses a pricing plan order.
Description
The pauseOrder()
function returns a Promise that resolves when the order is successfully paused.
For orders with recurring payments, pauseOrder()
also pauses the payment schedule. Buyers are not charged when an order is paused. Use pauseOrder()
, for example, if the buyer is away and would like to put their pricing plan membership on hold until they return. Pausing an order affects the end date of the order by adding the time the order is paused to the endDate
. You can only pause orders with an "ACTIVE
" status.
Pausing an order causes the following changes:
- The order status changes to
"PAUSED"
. - The
pausePeriods
array is updated.
The endDate
and the earliestEndDate
for the order are adjusted to include the pause period when the order is resumed.
Paused orders can be continued with the resumeOrder()
function.
This function requires elevated permissions to run. This function is not universal and runs only on the backend.
Syntax
function pauseOrder(_id: string): Promise<void>
pauseOrder Parameters
NAME
TYPE
DESCRIPTION
Order ID.
Returns
Fulfilled - When the order is paused.
Return Type:
Was this helpful?
1import { orders } from 'wix-pricing-plans.v2';2import { elevate } from 'wix-auth';34/* Sample _id value: '9af3cbe6-fe27-4fdb-a0b0-892289b03d22' */56const elevatedPauseOrder = elevate(orders.pauseOrder);78export async function myPauseOrderFunction(_id) {9 try {10 await elevatedPauseOrder(_id);1112 return;13 } catch (error) {14 console.error(error);15 // Handle the error16 }17}1819/* Promise resolves to void */
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 elevatedPauseOrder = elevate(orders.pauseOrder);89export const myPauseOrderFunction = webMethod(Permissions.Anyone, async (_id) => {10 try {11 await elevatedPauseOrder(_id);1213 return;14 } catch (error) {15 console.error(error);16 // Handle the error17 }18});1920/* Promise resolves to void */21
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}