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 (dashboard page code)
Copy Code
1import { plans } from 'wix-pricing-plans.v2';23export async function myGetPlanStatsFunction() {4 try {5 const planStats = plans.getPlanStats();67 return planStats;8 } catch (error) {9 console.error(error);10 // Handle the error11 }12}1314/* Promise resolves to:15 * {16 * "totalPlans": 817 * }18 */
Get number of 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 myGetPlanStatsFunction = webMethod(Permissions.Anyone, async () => {6 try {7 const elevatedGetPlanStats = elevate(plans.getPlanStats);8 const planStats = elevatedGetPlanStats();910 return planStats;11 } catch (error) {12 console.error(error);13 // Handle the error14 }15});1617/* Promise resolves to:18 * {19 * "totalPlans": 820 * }21 */22