updatePlan( )


Updates a pricing plan. Updating a plan doesn't impact existing orders made for the plan. All orders keep the details of the original plan that was active at the time of purchase.

Authentication

This function requires elevated permissions and runs only on the backend and on dashboard pages.

Permissions
Manage Pricing Plans
Learn more about app permissions.
Method Declaration
Copy
function updatePlan(
  _id: string,
  plan: UpdatePlan,
  options: UpdatePlanOptions,
): Promise<Plan>;
Method Parameters
_idstringRequired

ID of the plan to update.


planUpdatePlanRequired

optionsUpdatePlanOptions

Options for updating the plan.

Returns
Return Type:Promise<Plan>
JavaScript
import { plans } from "wix-pricing-plans.v2"; /* Sample _id value: '025a0d1f-7076-4e27-9696-4a67075dc2aa' * * Sample plan value: * { * description: 'Bronze membership to the MyGame World of Online Gaming', * name: 'Bronze Plan' * } */ export async function myUpdatePlanFunction(_id, plan) { try { const updatedPlan = await plans.updatePlan(_id, plan); return updatedPlan; } catch (errors) { console.error(errors); // Handle the error } } /* Promise resolves to: * { * "_createdDate": "2024-01-04T12:51:42.249Z", * "_id": "025a0d1f-7076-4e27-9696-4a67075dc2aa", * "_updatedDate": "2024-01-07T12:53:53.562Z", * "allowFutureStartDate": true, * "archived": false, * "buyerCanCancel": true, * "description": "Bronze membership to the MyGame World of Online Gaming", * "formId": "ee62cefa-bdc2-4b5d-baab-6faeef83cecb", * "hasOrders": false, * "maxPurchasesPerBuyer": 1, * "name": "Bronze Plan", * "perks": { * "values": [ * "Multiplayer", * "Multiple devices", * "No ads", * "Unlimited access" * ] * }, * "pricing": { * "price": { * "currency": "USD", * "value": "10.00" * }, * "singlePaymentUnlimited": true * }, * "primary": false, * "public": false, * "slug": "bronze-plan-1", * "termsAndConditions": "No sharing access with others!" * } */
Errors
400Invalid Argument

There are 17 errors with this status code.

428Failed Precondition

There is 1 error with this status code.

This method may also return standard errors. Learn more about standard Wix errors.

Did this help?