Search.../

getProgramTotals( )

Developer Preview

Retrieves the total amount of points earned, redeemed, and adjusted for the entire loyalty program.

Description

The getProgramTotals() function returns a Promise that resolves to the combined total points for all loyalty accounts in the program.

The balance is the current total of points outstanding, while the earned, adjusted, and redeemed amounts are the all-time accumulated amounts. The totals include the amounts for all loyalty accounts.

Note: Only visitors with Manage Loyalty permissions can retrieve the loyalty program totals.

Admin Method

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

Syntax

function getProgramTotals(): Promise<GetProgramTotalsResponse>

getProgramTotals Parameters

This function does not take any parameters.

Returns

Return Type:

Promise<
GetProgramTotalsResponse
>
NAME
TYPE
DESCRIPTION
points
Points

Point totals for the entire program.

Was this helpful?

Get the total points for the entire loyalty program (dashboard page code)

Copy Code
1import { accounts } from 'wix-loyalty.v2';
2
3export async function myGetProgramTotalsFunction() {
4 try {
5 const programTotals = await accounts.getProgramTotals();
6
7 const currentBalance = programTotals.points.balance;
8 const redeemed = programTotals.points.redeemed;
9
10 console.log('Success! ', redeemed, ' total points have been redeemed in the life of this program.');
11
12 return programTotals;
13 } catch (error) {
14 console.error(error);
15 }
16}
17
18/* Promise resolves to:
19 * {
20 * "points": {
21 * "balance": 2046,
22 * "earned": 1475,
23 * "adjusted": 571,
24 * "redeemed": 0
25 * }
26 * }
27 */
28
Get the total points for the entire loyalty program (export from backend code)

Copy Code
1import { Permissions, webMethod } from 'wix-web-module';
2import { accounts } from 'wix-loyalty.v2';
3
4export const myGetProgramTotalsFunction = webMethod(Permissions.Anyone, async () => {
5 try {
6 const programTotals = await accounts.getProgramTotals();
7
8 const currentBalance = programTotals.points.balance;
9 const redeemed = programTotals.points.redeemed;
10
11 console.log('Success! ', redeemed, ' total points have been redeemed in the life of this program.');
12
13 return programTotals;
14 } catch (error) {
15 console.error(error);
16 }
17});
18
19/* Promise resolves to:
20 * {
21 * "points": {
22 * "balance": 2046,
23 * "earned": 1475,
24 * "adjusted": 571,
25 * "redeemed": 0
26 * }
27 * }
28 */
29