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.
Authorization
Request
This endpoint does not take any parameters
Response Object
NAME
TYPE
DESCRIPTION
points
Points
Point totals for the entire program.
Status/Error Codes
Was this helpful?
Get the total points for the entire loyalty program (dashboard page code)
Copy Code
1import { accounts } from 'wix-loyalty.v2';23export async function myGetProgramTotalsFunction() {4 try {5 const programTotals = await accounts.getProgramTotals();67 const currentBalance = programTotals.points.balance;8 const redeemed = programTotals.points.redeemed;910 console.log('Success! ', redeemed, ' total points have been redeemed in the life of this program.');1112 return programTotals;13 } catch (error) {14 console.error(error);15 }16}1718/* Promise resolves to:19 * {20 * "points": {21 * "balance": 2046,22 * "earned": 1475,23 * "adjusted": 571,24 * "redeemed": 025 * }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';34export const myGetProgramTotalsFunction = webMethod(Permissions.Anyone, async () => {5 try {6 const programTotals = await accounts.getProgramTotals();78 const currentBalance = programTotals.points.balance;9 const redeemed = programTotals.points.redeemed;1011 console.log('Success! ', redeemed, ' total points have been redeemed in the life of this program.');1213 return programTotals;14 } catch (error) {15 console.error(error);16 }17});1819/* Promise resolves to:20 * {21 * "points": {22 * "balance": 2046,23 * "earned": 1475,24 * "adjusted": 571,25 * "redeemed": 026 * }27 * }28 */29