Search...
listPublicPlans( )
Retrieves a list of public pricing plans.
Description
The listPublicPlans()
function returns a Promise that resolves to a list of up to 100 public pricing plans. Public plans are visible plans that site visitors can see on the site and purchase.
Syntax
function listPublicPlans(options: ListPublicPlansOptions): Promise<ListPublicPlansResponse>
listPublicPlans Parameters
NAME
TYPE
DESCRIPTION
options
Optional
ListPublicPlansOptions
Options for filtering and paging the list of public plans.
Returns
Fulfilled - List of public pricing plans.
Return Type:
Promise<
ListPublicPlansResponse
>NAME
TYPE
DESCRIPTION
pagingMetadata
PagingMetadataV2
Details on the paged set of public pricing plans returned.
plans
Array<
PublicPlan
>List of public pricing plans.
Was this helpful?
List public plans
Copy Code
1import { plans } from 'wix-pricing-plans.v2';2import { elevate } from 'wix-auth';34export async function myListPublicPlansFunction() {5 try {6 const elevatedListPublicPlans = elevate(plans.listPublicPlans);7 const plansList = await elevatedListPublicPlans();89 return plansList;10 } catch(error) {11 console.error(error);12 // Handle the error13 }14}1516/* Promise resolves to:17 * {18 * "pagingMetadata": {19 * "count": 5,20 * "hasNext": false,21 * "offset": 0,22 * "total": 523 * },24 * "plans": [25 * {26 * "_createdDate": "2024-01-08T14:33:12.209Z",27 * "_id": "d2fa5805-0d1a-4cfb-9b43-e683cf5fa990",28 * "_updatedDate": "2024-01-08T14:33:12.209Z",29 * "allowFutureStartDate": false,30 * "archived": false,31 * "buyerCanCancel": true,32 * "description": "The value plan",33 * "formId": "ee62cefa-bdc2-4b5d-baab-6faeef83cecb",34 * "hasOrders": false,35 * "maxPurchasesPerBuyer": 1,36 * "name": "Silver Membership - Monthly",37 * "perks": {38 * "values": [39 * "Full site access",40 * "Full video access",41 * "Consultation booking"42 * ]43 * },44 * "primary": false,45 * "pricing": {46 * "freeTrialDays": 14,47 * "price": {48 * "currency": "EUR",49 * "value": "100"50 * },51 * "slug": "silver-membership-monthly",52 * "subscription": {53 * "cycleCount": 0,54 * "cycleDuration": {55 * "count": 1,56 * "unit": "MONTH"57 * }58 * }59 * },60 * "termsAndConditions": ""61 * },62 * {63 * "_createdDate": "2024-01-07T07:33:59.973Z",64 * "_id": "b20feb39-a452-453e-96ee-01036adcd04e",65 * "_updatedDate": "2024-01-09T09:08:05.665Z",66 * "allowFutureStartDate": false,67 * "archived": false,68 * "buyerCanCancel": true,69 * "description": "Full feature enablement - lifetime plan",70 * "formId": "ee62cefa-bdc2-4b5d-baab-6faeef83cecb",71 * "hasOrders": false,72 * "maxPurchasesPerBuyer": 0,73 * "name": "Premium Plan - Lifetime Membership",74 * "perks": {75 * "values": [76 * "Cloud drive and file upload services",77 * "Unlimited video content access"78 * ]79 * },80 * "primary": false,81 * "pricing": {82 * "price": {83 * "currency": "EUR",84 * "value": "1000"85 * },86 * "singlePaymentUnlimited": true87 * },88 * "slug": "premium-plan-lifetime-membership",89 * "termsAndConditions": "This plan allows unlimited app and site features usage for all time, subject to our fair usage agreement and basic human decency agreement.",90 * },91 * {92 * "_createdDate": "2024-01-07T07:28:42.863Z",93 * "_id": "838f2c9d-c8d0-4799-a10a-e2f23849db10",94 * "_updatedDate": "2024-01-07T08:36:07.520Z",95 * "allowFutureStartDate": false,96 * "archived": false,97 * "buyerCanCancel": true,98 * "description": "Complete with all features. One month free trial.",99 * "formId": "ee62cefa-bdc2-4b5d-baab-6faeef83cecb",100 * "hasOrders": false,101 * "maxPurchasesPerBuyer": 0,102 * "name": "Premium Plan - annual - 30 day trial",103 * "perks": {104 * "values": [105 * "Unlimited video library streaming access",106 * "File sharing enabled for all channels"107 * ]108 * },109 * "primary": false,110 * "pricing": {111 * "cycleCount": 2,112 * "cycleDuration": {113 * "count": 1,114 * "unit": "YEAR"115 * },116 * "freeTrialDays": 30,117 * "price": {118 * "currency": "EUR",119 * "value": "500"120 * },121 * "subscription": {122 * "cycleCount": 2,123 * "cycleDuration": {124 * "count": 1,125 * "unit": "YEAR"126 * }127 * }128 * },129 * "slug": "premium-plan-annual-30-day-trial-1",130 * "termsAndConditions": "Unlimited usage of services, subject to Fair Usage and Code of Conduct policies.",131 * },132 * {133 * "_createdDate": "2024-01-07T07:10:30.074Z",134 * "_id": "cb4a8c57-273a-4567-94e3-cc43d5d339f2",135 * "_updatedDate": "2024-01-07T07:10:30.074Z",136 * "allowFutureStartDate": false,137 * "archived": false,138 * "buyerCanCancel": true,139 * "description": "3 mo free trial with discount for 1 year",140 * "formId": "ee62cefa-bdc2-4b5d-baab-6faeef83cecb",141 * "hasOrders": false,142 * "maxPurchasesPerBuyer": 0,143 * "name": "Beginner's Plan",144 * "perks": {145 * "values": []146 * },147 * "primary": false,148 * "pricing": {149 * "cycleCount": 2,150 * "cycleDuration": {151 * "count": 1,152 * "unit": "YEAR"153 * },154 * "freeTrialDays": 90,155 * "price": {156 * "currency": "EUR",157 * "value": "50"158 * }159 * },160 * "slug": "beginners-plan",161 * "termsAndConditions": ""162 * },163 * {164 * "_createdDate": "2024-01-07T08:18:16.411Z",165 * "_id": "7a3375ce-18a9-42cb-8e39-47918ade45ec",166 * "_updatedDate": "2024-01-07T08:18:16.411Z",167 * "allowFutureStartDate": false,168 * "archived": false,169 * "buyerCanCancel": true,170 * "description": "Affordable with great functionality. Expires after 1 year",171 * "formId": "ee62cefa-bdc2-4b5d-baab-6faeef83cecb",172 * "hasOrders": false,173 * "maxPurchasesPerBuyer": 0,174 * "name": "Basic Plan - monthly subscription",175 * "perks": {176 * "values": [177 * "Access to select video channels",178 * "Access to rich site content",179 * "Access to designated file store"180 * ]181 * },182 * "primary": false,183 * "pricing": {184 * "cycleCount": 12,185 * "cycleDuration": {186 * "count": 1,187 * "unit": "MONTH"188 * },189 * "price": {190 * "currency": "EUR",191 * "value": "5"192 * },193 * "slug": "basic-plan-monthly-subscription"194 * },195 * "termsAndConditions": ""196 * }197 * ],198 * }199 */
List public plans (export from backend code)
Copy Code
1import { Permissions, webMethod } from 'wix-web-module';2import { plans } from 'wix-pricing-plans.v2';3import { elevate } from 'wix-auth';45export const myListPublicPlansFunction = webMethod(Permissions.Anyone, async () => {6 try {7 const elevatedListPublicPlans = elevate(plans.listPublicPlans);8 const plansList = await elevatedListPublicPlans();910 return plansList;11 } catch(error) {12 console.error(error);13 // Handle the error14 }15});1617/* Promise resolves to:18 * {19 * "pagingMetadata": {20 * "count": 5,21 * "hasNext": false,22 * "offset": 0,23 * "total": 524 * },25 * "plans": [26 * {27 * "_createdDate": "2024-01-08T14:33:12.209Z",28 * "_id": "d2fa5805-0d1a-4cfb-9b43-e683cf5fa990",29 * "_updatedDate": "2024-01-08T14:33:12.209Z",30 * "allowFutureStartDate": false,31 * "archived": false,32 * "buyerCanCancel": true,33 * "description": "The value plan",34 * "formId": "ee62cefa-bdc2-4b5d-baab-6faeef83cecb",35 * "hasOrders": false,36 * "maxPurchasesPerBuyer": 1,37 * "name": "Silver Membership - Monthly",38 * "perks": {39 * "values": [40 * "Full site access",41 * "Full video access",42 * "Consultation booking"43 * ]44 * },45 * "primary": false,46 * "pricing": {47 * "freeTrialDays": 14,48 * "price": {49 * "currency": "EUR",50 * "value": "100"51 * },52 * "slug": "silver-membership-monthly",53 * "subscription": {54 * "cycleCount": 0,55 * "cycleDuration": {56 * "count": 1,57 * "unit": "MONTH"58 * }59 * }60 * },61 * "termsAndConditions": ""62 * },63 * {64 * "_createdDate": "2024-01-07T07:33:59.973Z",65 * "_id": "b20feb39-a452-453e-96ee-01036adcd04e",66 * "_updatedDate": "2024-01-09T09:08:05.665Z",67 * "allowFutureStartDate": false,68 * "archived": false,69 * "buyerCanCancel": true,70 * "description": "Full feature enablement - lifetime plan",71 * "formId": "ee62cefa-bdc2-4b5d-baab-6faeef83cecb",72 * "hasOrders": false,73 * "maxPurchasesPerBuyer": 0,74 * "name": "Premium Plan - Lifetime Membership",75 * "perks": {76 * "values": [77 * "Cloud drive and file upload services",78 * "Unlimited video content access"79 * ]80 * },81 * "primary": false,82 * "pricing": {83 * "price": {84 * "currency": "EUR",85 * "value": "1000"86 * },87 * "singlePaymentUnlimited": true88 * },89 * "slug": "premium-plan-lifetime-membership",90 * "termsAndConditions": "This plan allows unlimited app and site features usage for all time, subject to our fair usage agreement and basic human decency agreement.",91 * },92 * {93 * "_createdDate": "2024-01-07T07:28:42.863Z",94 * "_id": "838f2c9d-c8d0-4799-a10a-e2f23849db10",95 * "_updatedDate": "2024-01-07T08:36:07.520Z",96 * "allowFutureStartDate": false,97 * "archived": false,98 * "buyerCanCancel": true,99 * "description": "Complete with all features. One month free trial.",100 * "formId": "ee62cefa-bdc2-4b5d-baab-6faeef83cecb",101 * "hasOrders": false,102 * "maxPurchasesPerBuyer": 0,103 * "name": "Premium Plan - annual - 30 day trial",104 * "perks": {105 * "values": [106 * "Unlimited video library streaming access",107 * "File sharing enabled for all channels"108 * ]109 * },110 * "primary": false,111 * "pricing": {112 * "cycleCount": 2,113 * "cycleDuration": {114 * "count": 1,115 * "unit": "YEAR"116 * },117 * "freeTrialDays": 30,118 * "price": {119 * "currency": "EUR",120 * "value": "500"121 * },122 * "subscription": {123 * "cycleCount": 2,124 * "cycleDuration": {125 * "count": 1,126 * "unit": "YEAR"127 * }128 * }129 * },130 * "slug": "premium-plan-annual-30-day-trial-1",131 * "termsAndConditions": "Unlimited usage of services, subject to Fair Usage and Code of Conduct policies.",132 * },133 * {134 * "_createdDate": "2024-01-07T07:10:30.074Z",135 * "_id": "cb4a8c57-273a-4567-94e3-cc43d5d339f2",136 * "_updatedDate": "2024-01-07T07:10:30.074Z",137 * "allowFutureStartDate": false,138 * "archived": false,139 * "buyerCanCancel": true,140 * "description": "3 mo free trial with discount for 1 year",141 * "formId": "ee62cefa-bdc2-4b5d-baab-6faeef83cecb",142 * "hasOrders": false,143 * "maxPurchasesPerBuyer": 0,144 * "name": "Beginner's Plan",145 * "perks": {146 * "values": []147 * },148 * "primary": false,149 * "pricing": {150 * "cycleCount": 2,151 * "cycleDuration": {152 * "count": 1,153 * "unit": "YEAR"154 * },155 * "freeTrialDays": 90,156 * "price": {157 * "currency": "EUR",158 * "value": "50"159 * }160 * },161 * "slug": "beginners-plan",162 * "termsAndConditions": ""163 * },164 * {165 * "_createdDate": "2024-01-07T08:18:16.411Z",166 * "_id": "7a3375ce-18a9-42cb-8e39-47918ade45ec",167 * "_updatedDate": "2024-01-07T08:18:16.411Z",168 * "allowFutureStartDate": false,169 * "archived": false,170 * "buyerCanCancel": true,171 * "description": "Affordable with great functionality. Expires after 1 year",172 * "formId": "ee62cefa-bdc2-4b5d-baab-6faeef83cecb",173 * "hasOrders": false,174 * "maxPurchasesPerBuyer": 0,175 * "name": "Basic Plan - monthly subscription",176 * "perks": {177 * "values": [178 * "Access to select video channels",179 * "Access to rich site content",180 * "Access to designated file store"181 * ]182 * },183 * "primary": false,184 * "pricing": {185 * "cycleCount": 12,186 * "cycleDuration": {187 * "count": 1,188 * "unit": "MONTH"189 * },190 * "price": {191 * "currency": "EUR",192 * "value": "5"193 * },194 * "slug": "basic-plan-monthly-subscription"195 * },196 * "termsAndConditions": ""197 * }198 * ],199 * }200 */201
List public plans with options
Copy Code
1import { Permissions, webMethod } from 'wix-web-module';2import { plans } from 'wix-pricing-plans.v2';3import { elevate } from 'wix-auth';45/* Sample options value:6 * {7 * limit: 3,8 * offset: 1,9 * planIds: [10 * "d2fa5805-0d1a-4cfb-9b43-e683cf5fa990",11 * "b20feb39-a452-453e-96ee-01036adcd04e",12 * "025a0d1f-7076-4e27-9696-4a67075dc2aa",13 * "838f2c9d-c8d0-4799-a10a-e2f23849db10",14 * "cb4a8c57-273a-4567-94e3-cc43d5d339f2",15 * "7a3375ce-18a9-42cb-8e39-47918ade45ec"16 * ]17 * }18 */1920export const myListPublicPlansFunction = webMethod(Permissions.Anyone, async (options) => {21 try {22 const elevatedListPublicPlans = elevate(plans.listPublicPlans);23 const plansList = await elevatedListPublicPlans(options);2425 return plansList;26 } catch(error) {27 console.error(error);28 // Handle the error29 }30});3132/* Promise resolves to:33 * {34 * "pagingMetadata": {35 * "count": 3,36 * "hasNext": true,37 * "offset": 1,38 * "total": 539 * },40 * "plans": [41 * {42 * "_createdDate": "2024-01-07T07:33:59.973Z",43 * "_id": "b20feb39-a452-453e-96ee-01036adcd04e",44 * "_updatedDate": "2024-01-09T09:08:05.665Z",45 * "allowFutureStartDate": false,46 * "archived": false,47 * "buyerCanCancel": true,48 * "description": "Full feature enablement - lifetime plan",49 * "formId": "ee62cefa-bdc2-4b5d-baab-6faeef83cecb",50 * "hasOrders": false,51 * "maxPurchasesPerBuyer": 0,52 * "name": "Premium Plan - Lifetime Membership",53 * "perks": {54 * "values": [55 * "Cloud drive and file upload services",56 * "Unlimited video content access"57 * ]58 * },59 * "primary": false,60 * "pricing": {61 * "price": {62 * "currency": "EUR",63 * "value": "1000"64 * },65 * "singlePaymentUnlimited": true66 * },67 * "slug": "premium-plan-lifetime-membership",68 * "termsAndConditions": "This plan allows unlimited app and site features usage for all time, subject to our fair usage agreement and basic human decency agreement.",69 * },70 * {71 * "_createdDate": "2024-01-07T07:28:42.863Z",72 * "_id": "838f2c9d-c8d0-4799-a10a-e2f23849db10",73 * "_updatedDate": "2024-01-07T08:36:07.520Z",74 * "allowFutureStartDate": false,75 * "archived": false,76 * "buyerCanCancel": true,77 * "description": "Complete with all features. One month free trial.",78 * "formId": "ee62cefa-bdc2-4b5d-baab-6faeef83cecb",79 * "hasOrders": false,80 * "maxPurchasesPerBuyer": 0,81 * "name": "Premium Plan - annual - 30 day trial",82 * "perks": {83 * "values": [84 * "Unlimited video library streaming access",85 * "File sharing enabled for all channels"86 * ]87 * },88 * "primary": false,89 * "pricing": {90 * "cycleCount": 2,91 * "cycleDuration": {92 * "count": 1,93 * "unit": "YEAR"94 * },95 * "freeTrialDays": 30,96 * "price": {97 * "currency": "EUR",98 * "value": "500"99 * },100 * "subscription": {101 * "cycleCount": 2,102 * "cycleDuration": {103 * "count": 1,104 * "unit": "YEAR"105 * }106 * }107 * },108 * "slug": "premium-plan-annual-30-day-trial-1",109 * "termsAndConditions": "Unlimited usage of services, subject to Fair Usage and Code of Conduct policies.",110 * },111 * {112 * "_createdDate": "2024-01-07T07:10:30.074Z",113 * "_id": "cb4a8c57-273a-4567-94e3-cc43d5d339f2",114 * "_updatedDate": "2024-01-07T07:10:30.074Z",115 * "allowFutureStartDate": false,116 * "archived": false,117 * "buyerCanCancel": true,118 * "description": "3 mo free trial with discount for 1 year",119 * "formId": "ee62cefa-bdc2-4b5d-baab-6faeef83cecb",120 * "hasOrders": false,121 * "maxPurchasesPerBuyer": 0,122 * "name": "Beginner's Plan",123 * "perks": {124 * "values": []125 * },126 * "primary": false,127 * "pricing": {128 * "cycleCount": 2,129 * "cycleDuration": {130 * "count": 1,131 * "unit": "YEAR"132 * },133 * "freeTrialDays": 90,134 * "price": {135 * "currency": "EUR",136 * "value": "50"137 * },138 * },139 * "slug": "beginners-plan",140 * "termsAndConditions": "",141 * }142 * ]143 * }144 */
Make a plan primary
Select a public plan from the dropdown to make it appear as a primary plan on the business site.
Copy Code
1/*************************************2 * Backend code - plan-functions.web.js *3 *************************************/45import { Permissions, webMethod } from 'wix-web-module';6import { plans } from 'wix-pricing-plans.v2';7import { elevate } from 'wix-auth';89const elevatedListPublicPlans = elevate(plans.listPublicPlans);10const elevatedMakePlanPrimary = elevate(plans.makePlanPrimary);1112export const listPublicPlans = webMethod(Permissions.Anyone, async () => {13 try {14 const response = await elevatedListPublicPlans();15 const plansList = response.plans;1617 return plansList;18 } catch (error) {19 console.error(error);20 // Handle the error21 }22});2324export const makePlanPrimaryFunction = webMethod(Permissions.Anyone, async (_id) => {25 try {26 const primaryPlan = await elevatedMakePlanPrimary(_id);2728 return primaryPlan;29 } catch (error) {30 console.error(error);31 // Handle the error32 }33});3435/*************36 * Page code *37 *************/3839import { listPublicPlans, makePlanPrimaryFunction } from 'backend/plan-functions.web';4041$w.onReady(function () {42 populateDropdown();43 $w('#plansList').onChange(async () => {44 await makePlanPrimaryFunction(45 $w('#plansList').value46 )47 });48});4950async function populateDropdown() {51 const plans = await listPublicPlans();52 $w('#plansList').options = plans.map(item => ({53 label: item.name,54 value: item._id55 })56 )57}