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
The information for the plan being updated.
Returns
Fulfilled - The updated plan. Rejected - Error message.
Return Type:
NAME
TYPE
DESCRIPTION
Plan ID.
Plan name.
Plan description.
List of text strings that promote the pricing plan (for example, "Plenty of parking" or "Free gift on your birthday").
Plan price, payment schedule, and expiration.
Whether the plan is public (visible to site visitors).
Whether the plan is archived. Archived plans are not visible and can't be purchased anymore, but existing purchases remain in effect.
Whether the plan is marked as primary. If true
, the plan is highlighted on the site with a custom ribbon. Defaults to false
.
Whether the plan has any orders (including pending and unpaid orders).
Date plan was created.
Date plan was last updated.
URL-friendly version of the plan name. Unique across all plans in the same site.
Whether the buyer can start the plan at a later date.
Whether the buyer is allowed to cancel their plan. If false
, calling the cancelOrder()
function returns an error.
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.
Any terms and conditions that apply to the plan. This information is displayed during checkout.
Was this helpful?
Update a plan
1/*******************************2 * Backend code - plans.jsw *3 *******************************/45import wixPricingPlansBackend from 'wix-pricing-plans-backend';67export function myUpdatePlanFunction(planInfo) {8 return wixPricingPlansBackend.updatePlan(planInfo);9}1011/*************12 * Page code *13 *************/1415import { myUpdatePlanFunction } from 'backend/plans';1617// …1819const planInfo = {20 "_id": "3743d382-a4d4-7e15-ada5-340ad4b5d760",21 "name": "Gold Plus",22 "description": "Updated description for the original Gold plan",23 "maxPurchasesPerBuyer": 1,24 "primary": false,25 "public": false,26 "termsAndConditions": ""27}2829myUpdatePlanFunction(planInfo)30 .then(plan => {31 // plan updated32 const planId = plan._id;33 const description = plan.description;34 })35 .catch((error) => {36 // plan not updated37 const updateError = error;38 });394041/* Full plan object:42 *43 * {44 * "_id": "3743d382-a4d4-7e15-ada5-340ad4b5d760",45 * "name": "Gold Plus",46 * "description": "Updated description for the original Gold plan",47 * "perks": [48 * "Multiplayer",49 * "Multiple devices",50 * "No ads",51 * "Unlimited access"52 * ],53 * "pricing": {54 * "price": {55 * "value": "10.00",56 * "currency": "USD"57 * },58 * "singlePaymentUnlimited": true59 * },60 * "public": false,61 * "archived": false,62 * "primary": false,63 * "hasOrders": false,64 * "_createdDate": "2020-12-21T09:38:14.939Z",65 * "_updatedDate": "2020-12-30T09:09:10.939Z",66 * "slug": "gold-plus",67 * "maxPurchasesPerBuyer": 1,68 * "allowFutureStartDate": true,69 * "buyerCanCancel": true,70 * "termsAndConditions": ""71 * }72 */