Search.../

updatePlan( )

Updates a pricing plan.

Description

The updatePlan() function returns a Promise that resolves to an updated plan.

Updating a plan does not impact existing purchases made for the plan. All purchases keep the details of the original plan that was active at the time of purchase.

Only users with "Manage Pricing Plans" permissions can update plans.

Syntax

function updatePlan(planInfo: UpdatePlanInfo): Promise<Plan>

updatePlan Parameters

NAME
TYPE
DESCRIPTION
planInfo
UpdatePlanInfo

The information for the plan being updated.

Returns

Fulfilled - The updated plan. Rejected - Error message.

Return Type:

Promise<Plan>
NAME
TYPE
DESCRIPTION
_id
string

Plan ID.

name
string

Plan name.

description
string

Plan description.

perks
Array<string>

List of text strings that promote the pricing plan (for example, "Plenty of parking" or "Free gift on your birthday").

pricing
Pricing

Plan price, payment schedule, and expiration.

public
boolean

Whether the plan is public (visible to site visitors).

archived
boolean

Whether the plan is archived. Archived plans are not visible and can't be purchased anymore, but existing purchases remain in effect.

primary
boolean

Whether the plan is marked as primary. If true, the plan is highlighted on the site with a custom ribbon. Defaults to false.

hasOrders
boolean

Whether the plan has any orders (including pending and unpaid orders).

_createdDate
Date

Date plan was created.

_updatedDate
Date

Date plan was last updated.

slug
string

URL-friendly version of the plan name. Unique across all plans in the same site.

allowFutureStartDate
boolean

Whether the buyer can start the plan at a later date.

buyerCanCancel
boolean

Whether the buyer is allowed to cancel their plan. If false, calling the cancelOrder() function returns an error.

maxPurchasesPerBuyer
number

Whether the same buyer can purchase the plan multiple times. 1 means the buyer can only purchase the plan once. An empty value or 0 means no limitation.

termsAndConditions
string

Any terms and conditions that apply to the plan. This information is displayed during checkout.

Was this helpful?

Update a plan

Copy Code
1/*******************************
2 * Backend code - plans.web.js *
3 *******************************/
4
5import { Permissions, webMethod } from 'wix-web-module';
6import wixPricingPlansBackend from 'wix-pricing-plans-backend';
7
8export const myUpdatePlanFunction = webMethod(Permissions.Anyone, (planInfo) => {
9 return wixPricingPlansBackend.updatePlan(planInfo);
10});
11
12/*************
13 * Page code *
14 *************/
15
16import { myUpdatePlanFunction } from 'backend/plans.web';
17
18// …
19
20const planInfo = {
21 "_id": "3743d382-a4d4-7e15-ada5-340ad4b5d760",
22 "name": "Gold Plus",
23 "description": "Updated description for the original Gold plan",
24 "maxPurchasesPerBuyer": 1,
25 "primary": false,
26 "public": false,
27 "termsAndConditions": ""
28}
29
30myUpdatePlanFunction(planInfo)
31 .then(plan => {
32 // plan updated
33 const planId = plan._id;
34 const description = plan.description;
35 })
36 .catch((error) => {
37 // plan not updated
38 const updateError = error;
39 });
40
41
42/* Full plan object:
43 *
44 * {
45 * "_id": "3743d382-a4d4-7e15-ada5-340ad4b5d760",
46 * "name": "Gold Plus",
47 * "description": "Updated description for the original Gold plan",
48 * "perks": [
49 * "Multiplayer",
50 * "Multiple devices",
51 * "No ads",
52 * "Unlimited access"
53 * ],
54 * "pricing": {
55 * "price": {
56 * "value": "10.00",
57 * "currency": "USD"
58 * },
59 * "singlePaymentUnlimited": true
60 * },
61 * "public": false,
62 * "archived": false,
63 * "primary": false,
64 * "hasOrders": false,
65 * "_createdDate": "2020-12-21T09:38:14.939Z",
66 * "_updatedDate": "2020-12-30T09:09:10.939Z",
67 * "slug": "gold-plus",
68 * "maxPurchasesPerBuyer": 1,
69 * "allowFutureStartDate": true,
70 * "buyerCanCancel": true,
71 * "termsAndConditions": ""
72 * }
73 */