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

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