Search.../

getPlanStats( )

Retrieves statistics about the pricing plans.

Description

The getPlanStats() function returns a Promise that resolves to statistics about the plan on the site.

Currently this function provides only the total number of pricing plans, including archived plans.

Admin Method

This function requires elevated permissions to run. This function is not universal and runs only on the backend.

Syntax

function getPlanStats(): Promise<GetPlanStatsResponse>

getPlanStats Parameters

This function does not take any parameters.

Returns

Fulfilled - Overall statistics about the pricing plans.

Return Type:

Promise<
GetPlanStatsResponse
>
NAME
TYPE
DESCRIPTION
totalPlans
number

Total number of plans created, including active plans (both public and hidden) and archived plans.

Was this helpful?

Get number of plans

Copy Code
1import { plans } from 'wix-pricing-plans.v2';
2import { elevate } from 'wix-auth';
3
4export async function myGetPlanStatsFunction() {
5 try {
6 const elevatedGetPlanStats = elevate(plans.getPlanStats);
7 const planStats = elevatedGetPlanStats();
8
9 return planStats;
10 } catch (error) {
11 console.error(error);
12 // Handle the error
13 }
14}
15
16/* Promise resolves to:
17 * {
18 * "totalPlans": 8
19 * }
20 */