Updates a pricing plan.
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 the purchase.
This function requires elevated permissions and runs only on the backend and on dashboard pages.
function updatePlan(
_id: string,
plan: UpdatePlan,
options: UpdatePlanOptions,
): Promise<Plan>;
ID of the plan to update.
Options for updating the plan.
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!"
* }
*/
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.