> 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: listPlans(options: ListPlansOptions) # Method package: wixPricingPlansV2 # Method menu location: wixPricingPlansV2 --> plans --> listPlans # Method Link: https://dev.wix.com/docs/velo/apis/wix-pricing-plans-v2/plans/list-plans.md # Method Description: Retrieves a list of up to 100 pricing plans (including public, hidden, and archived plans). # Method Code Examples: *** Note: do not assume any prop names or enum values other than the ones in the example. ## List all plans (dashboard page code) ```javascript import { plans } from 'wix-pricing-plans.v2'; import { elevate } from 'wix-auth'; const elevatedListPlans = elevate(plans.listPlans); export async function myListPlansFunction() { try { const plansList = await elevatedListPlans(); return plansList; } catch (error) { console.error(error); // Handle the error } } /* Promise resolves to: * [ * { * "_createdDate": "2024-01-08T14:33:12.209Z", * "_id": "d2fa5805-0d1a-4cfb-9b43-e683cf5fa990", * "_updatedDate": "2024-01-08T14:33:12.209Z", * "allowFutureStartDate": false, * "archived": false, * "buyerCanCancel": true, * "description": "The value plan", * "formId": "ee62cefa-bdc2-4b5d-baab-6faeef83cecb", * "hasOrders": false, * "maxPurchasesPerBuyer": 1, * "name": "Silver Membership - Monthly", * "perks": { * "values": [ * "Full site access", * "Full video access", * "Consultation booking" * ] * }, * "pricing": { * "cycleCount": 0, * "cycleDuration": { * "count": 1, * "unit": "MONTH" * }, * "freeTrialDays": 14, * "price": { * "currency": "EUR", * "value": "100" * }, * "subscription": { * "cycleCount": 0, * "cycleDuration": { * "count": 1, * "unit": "MONTH" * } * } * }, * "primary": false, * "public": true, * "slug": "silver-membership-monthly", * "termsAndConditions": "" * }, * { * "_createdDate": "2024-01-07T07:33:59.973Z", * "_id": "b20feb39-a452-453e-96ee-01036adcd04e", * "_updatedDate": "2024-01-09T09:08:05.665Z", * "allowFutureStartDate": false, * "archived": false, * "buyerCanCancel": true, * "description": "Full feature enablement - lifetime plan", * "formId": "ee62cefa-bdc2-4b5d-baab-6faeef83cecb", * "hasOrders": false, * "maxPurchasesPerBuyer": 0, * "name": "Premium Plan - Lifetime Membership", * "perks": { * "values": [ * "Cloud drive and file upload services", * "Unlimited video content access" * ] * }, * "pricing": { * "price": { * "currency": "EUR", * "value": "1000" * }, * "singlePaymentUnlimited": true * }, * "primary": false, * "public": true, * "slug": "premium-plan-lifetime-membership", * "termsAndConditions": "This plan allows unlimited app and site features usage for all time, subject to our fair usage agreement and basic human decency agreement." * }, * { * "_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!" * } * ] */ ``` ## List plans ```javascript import { Permissions, webMethod } from 'wix-web-module'; import { plans } from 'wix-pricing-plans.v2'; import { elevate } from 'wix-auth'; export const myListPlansFunction = webMethod(Permissions.Anyone, async () => { try { const elevatedListPlans = elevate(plans.listPlans); const plansList = await elevatedListPlans(); return plansList; } catch (error) { console.error(error); // Handle the error } }); /* Promise resolves to: * { * "pagingMetadata": { * "count": 4, * "offset": 0, * "total": 4 * }, * "plans": [ * { * "_createdDate": "2024-01-08T14:33:12.209Z", * "_id": "d2fa5805-0d1a-4cfb-9b43-e683cf5fa990", * "_updatedDate": "2024-01-08T14:33:12.209Z", * "allowFutureStartDate": false, * "archived": false, * "buyerCanCancel": true, * "description": "The value plan", * "formId": "ee62cefa-bdc2-4b5d-baab-6faeef83cecb", * "hasOrders": false, * "maxPurchasesPerBuyer": 1, * "name": "Silver Membership - Monthly", * "perks": { * "values": [ * "Full site access", * "Full video access", * "Consultation booking" * ] * }, * "pricing": { * "cycleCount": 0, * "cycleDuration": { * "count": 1, * "unit": "MONTH" * }, * "freeTrialDays": 14, * "price": { * "currency": "EUR", * "value": "100" * }, * "subscription": { * "cycleCount": 0, * "cycleDuration": { * "count": 1, * "unit": "MONTH" * } * } * }, * "primary": false, * "public": true, * "slug": "silver-membership-monthly", * "termsAndConditions": "" * }, * { * "_createdDate": "2024-01-07T07:33:59.973Z", * "_id": "b20feb39-a452-453e-96ee-01036adcd04e", * "_updatedDate": "2024-01-09T09:08:05.665Z", * "allowFutureStartDate": false, * "archived": false, * "buyerCanCancel": true, * "description": "Full feature enablement - lifetime plan", * "formId": "ee62cefa-bdc2-4b5d-baab-6faeef83cecb", * "hasOrders": false, * "maxPurchasesPerBuyer": 0, * "name": "Premium Plan - Lifetime Membership", * "perks": { * "values": [ * "Cloud drive and file upload services", * "Unlimited video content access" * ] * }, * "pricing": { * "price": { * "currency": "EUR", * "value": "1000" * }, * "singlePaymentUnlimited": true * }, * "primary": false, * "public": true, * "slug": "premium-plan-lifetime-membership", * "termsAndConditions": "This plan allows unlimited app and site features usage for all time, subject to our fair usage agreement and basic human decency agreement." * }, * { * "_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!" * } * ] * } */ ``` ## List plans with options ```javascript import { Permissions, webMethod } from 'wix-web-module'; import { plans } from 'wix-pricing-plans.v2'; import { elevate } from 'wix-auth'; /* Sample options value: * { * public: 'HIDDEN', * archived: 'ARCHIVED_AND_ACTIVE' * } */ export const myListPlansFunction = webMethod(Permissions.Anyone, async (options) => { try { const elevatedListPlans = elevate(plans.listPlans); const plansList = await elevatedListPlans(options); return plansList; } catch (error) { console.error(error); // Handle the error } }); /* Promise resolves to: * { * "pagingMetadata": { * "count": 4, * "offset": 0, * "total": 4 * }, * "plans": [ * { * "_createdDate": "2023-12-31T11:23:01.664Z", * "_id": "1421abaa-44c7-42ae-8a75-960fe7a8aa55", * "_updatedDate": "2024-01-08T11:24:18.561Z", * "allowFutureStartDate": false, * "archived": true, * "buyerCanCancel": true, * "description": "Free Plan", * "formId": "ee62cefa-bdc2-4b5d-baab-6faeef83cecb", * "hasOrders": false, * "maxPurchasesPerBuyer": 0, * "name": "Basic", * "perks": { * "values": [] * }, * "pricing": { * "price": { * "currency": "EUR", * "value": "0" * }, * "singlePaymentForDuration": { * "count": 3, * "unit": "MONTH" * } * }, * "primary": false, * "public": false, * "slug": "basic", * "termsAndConditions": "After 90 day free trial ends, your plan will end and you will need to purchase a paid plan." * }, * { * "_createdDate": "2024-01-04T12:28:21.004Z", * "_id": "97033d3e-b0ad-47d7-932c-197371aab9ec", * "_updatedDate": "2024-01-04T14:11:39.860Z", * "allowFutureStartDate": true, * "archived": true, * "buyerCanCancel": true, * "description": "Gold membership to the MyGame World of Online Gaming", * "formId": "ee62cefa-bdc2-4b5d-baab-6faeef83cecb", * "hasOrders": false, * "maxPurchasesPerBuyer": 1, * "name": "Gold", * "perks": { * "values": [ * "Multiplayer", * "Multiple devices", * "No ads", * "Unlimited access" * ] * }, * "pricing": { * "price": { * "currency": "USD", * "value": "10.00" * }, * "singlePaymentUnlimited": true * }, * "primary": false, * "public": false, * "slug": "gold", * "termsAndConditions": "No sharing access with others!" * }, * { * "_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", * "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!" * }, * { * "_createdDate": "2024-01-07T07:13:04.076Z", * "_id": "0b9a1993-c1ff-4952-9575-915b48d1a5e0", * "_updatedDate": "2024-01-09T12:32:26.807Z", * "allowFutureStartDate": false, * "archived": true, * "buyerCanCancel": true, * "description": "For new users just getting the feel of the product", * "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" * } * }, * "primary": false, * "public": false, * "slug": "simple-plan", * "termsAndConditions": "I agree to refrain from sharing any of the exclusive content with non-members" * } * ] * } */ ``` ## Duplicate a plan ```javascript /************************************* * Backend code - plan-functions.jsw * *************************************/ import { plans } from 'wix-pricing-plans.v2'; import { elevate } from 'wix-auth'; const elevatedListPlans = elevate(plans.listPlans); const elevatedGetPlan = elevate(plans.getPlan); const elevatedCreatePlan = elevate(plans.createPlan); export async function listPlans() { try { const response = await elevatedListPlans(); const allPlans = response.plans; return allPlans; } catch (error) { console.error(error); // Handle the error } } export async function getPlan(planId) { try { const selectedPlan = await elevatedGetPlan(planId); return selectedPlan; } catch (error) { console.error(error); // Handle the error } } export async function createPlan(plan) { try { const newPlan = await elevatedCreatePlan(plan); return newPlan; } catch (error) { console.error(error); // Handle the error } } /************* * Page code * *************/ import { listPlans, getPlan, createPlan } from 'backend/plan-functions'; $w.onReady(async function () { $w('#plansDropdown').disable(); $w('#clonePlanBtn').disable(); populatePlansDropdown(); let selectedPlan; $w('#plansDropdown').onChange(async () => { const planId = $w('#plansDropdown').value; selectedPlan = await getPlan(planId); // Set default value for the new plan name $w('#planName').value = `${selectedPlan.name}-duplicate` $w('#clonePlanBtn').enable(); }); $w('#clonePlanBtn').onClick(async () => { const newPlan = selectedPlan; // Use inputs to set the new plan name and price newPlan.name = $w('#planName').value; newPlan.pricing.price.value = $w('#price').value; await createPlan(newPlan); }); }); async function populatePlansDropdown() { const plans = await listPlans(); $w('#plansDropdown').options = plans.map((plan) => { return { label: plan.name, value: plan._id } }); $w('#plansDropdown').enable(); } ``` ---