> Portal Navigation: > > - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version. > - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages). > - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`). > - Top-level index of all portals: https://dev.wix.com/docs/llms.txt > - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt # Method name: updatePlan(_id: string, plan: UpdatePlan, options: UpdatePlanOptions) # Method package: wixPricingPlansV2 # Method menu location: wixPricingPlansV2 --> plans --> updatePlan # Method Link: https://dev.wix.com/docs/velo/apis/wix-pricing-plans-v2/plans/update-plan.md # Method Description: 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. # Method Code Examples: *** Note: do not assume any prop names or enum values other than the ones in the example. ## Update a plan (dashboard page code) ```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!" * } */ ``` ## Update a plan (export from backend code) ```javascript import { Permissions, webMethod } from 'wix-web-module'; import { plans } from 'wix-pricing-plans.v2'; import { elevate } from 'wix-auth'; /* 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 const myUpdatePlanFunction = webMethod(Permissions.Anyone, async (_id, plan) => { try { const elevateUpdatePlan = elevate(plans.updatePlan); const updatedPlan = await elevateUpdatePlan(_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!" * } */ ``` ## Update a plan with optional fields ```javascript import { Permissions, webMethod } from 'wix-web-module'; import { plans } from 'wix-pricing-plans.v2'; import { elevate } from 'wix-auth'; /* Sample _id value: '0b9a1993-c1ff-4952-9575-915b48d1a5e0' * * Sample plan value: * { * allowFutureStartDate: false, * buyerCanCancel: true, * description: 'For new users just getting the feel of the product', * formId: 'ee62cefa-bdc2-4b5d-baab-6faeef83cecb', * hasOrders: false, * maxPurchasesPerBuyer: 0, * name: 'Simple Plan', * perks: { * values: [ * 'Login member access', * 'Access to real-time articles', * 'Included in mailing list' * ] * }, * pricing: { * price: { * currency: 'USD', * value: '3' * }, * singlePaymentForDuration: { * count: 12, * unit: 'MONTH' * } * }, * public: true, * slug: 'simple-plan', * termsAndConditions: 'I agree to refrain from sharing any of the exclusive content with non-members' * } */ export const myUpdatePlanFunction = webMethod(Permissions.Anyone, async (_id, plan) => { try { const elevateUpdatePlan = elevate(plans.updatePlan); const updatedPlan = await elevateUpdatePlan(_id, plan); return updatedPlan; } catch (error) { console.error(error); // Handle the error } }); /* Promise resolves to: * { * "_createdDate": "2024-01-07T07:13:04.076Z", * "_id": "0b9a1993-c1ff-4952-9575-915b48d1a5e0", * "_updatedDate": "2024-01-07T11:02:55.945Z", * "allowFutureStartDate": false, * "archived": false, * "buyerCanCancel": true, * "description": "For new users just getting the feel of the product", * "formId": "ee62cefa-bdc2-4b5d-baab-6faeef83cecb", * "hasOrders": false, * "maxPurchasesPerBuyer": 0, * "name": "Simple Plan", * "perks": { * "values": [ * "Login member access", * "Access to real-time articles", * "Included in mailing list" * ] * }, * "pricing": { * "price": { * "value": "3", * "currency": "USD" * }, * "singlePaymentForDuration": { * "count": 12, * "unit": "MONTH" * } * }, * "primary": false, * "public": true, * "slug": "simple-plan" * "termsAndConditions": "I agree to refrain from sharing any of the exclusive content with non-members" * } */ ``` ---