Search.../

listPlans( )

Lists pricing plans.

Description

The listPlans() function returns a Promise that resolves to a list of up to 100 pricing plans.

Only users with "Manage Pricing Plans" permissions can use this function to list plans.

Syntax

function listPlans([planIds: Array<string>], [options: ListPlanInfo]): Promise<Array<Plans>>

listPlans Parameters

NAME
TYPE
DESCRIPTION
planIds
Optional
Array<string>

IDs of plans to list. You can pass a maximum of 50 IDs. If not specified, all public and hidden plans (based on the options) are listed (up to 50), according to the order displayed in the Dashboard. If non-existent IDs are specified, they are ignored and do not cause errors.

options
Optional
ListPlanInfo

Options to use when getting the list of plans.

Returns

Fulfilled - List of plans that match the given criteria.

Return Type:

Promise<Array<Plans>>
NAME
TYPE
DESCRIPTION
plans
Array<Plan>

List of public and hidden pricing plans.

Was this helpful?

List plans

Copy Code
1import wixPricingPlansBackend from 'wix-pricing-plans-backend';
2
3export function listPlans() {
4 const planIds = [
5 "001c0674-d7c9-4c77-acb5-b492b427b201",
6 "003d0674-d7c9-4d88-acb5-b492b427b302",
7 "011d0123-d7c9-5e44-acb5-d300a123b321"
8 ];
9 const options = {
10 limit: 10,
11 skip: 3,
12 archived: "ARCHIVED_AND_ACTIVE",
13 public: "PUBLIC_AND_HIDDEN"
14 }
15 return wixPricingPlansBackend.listPlans(planIds, options)
16 .then((plans) => {
17 // Array of all the specified pricing plan objects that match the criteria
18 console.log(plans);
19 })
20 .catch((error) => {
21 console.error(error);
22 });
23}
List archived plans

Copy Code
1/****************************
2 * Backend code - plans.jsw *
3 ****************************/
4import wixPricingPlansBackend from 'wix-pricing-plans-backend';
5
6export function listPlans(planIds, options) {
7 return wixPricingPlansBackend.listPlans(planIds, options);
8}
9
10/*************
11 * Page code *
12 *************/
13import { listPlans } from 'backend/plans';
14
15// ..
16
17$w("#listPlansButton").onClick((event) => {
18 const planIds = [];
19 const options = {
20 limit: 10,
21 skip: 1,
22 archived: "ARCHIVED"
23 }
24 listPlans(planIds, options)
25 .then((plans) => {
26 const firstPlanName = plans[0].name;
27 console.log("First plan is: " + firstPlanName + " and the rest are: ");
28 // Array of all the specified pricing plan objects that match the criteria
29 console.log(plans);
30 })
31 .catch((error) => {
32 console.error(error);
33 });
34});