getProgramTotals( )


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

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.

Authentication
  • When developing websites or building an app with Blocks, this method may require elevated permissions, depending on the identity of the user calling it and the calling user’s permissions.
  • When building apps without Blocks or for headless projects, you can only call this method directly when authenticated as a Wix app or Wix user identity. When authenticated as a different identity, you can call this method using elevation.
  • Elevation permits users to call methods they typically cannot access. Therefore, you should only use it intentionally and securely.
Permissions
Manage Loyalty
Read Loyalty
Learn more about app permissions.
Method Declaration
Copy
function getProgramTotals(): Promise<GetProgramTotalsResponse>;
Request
This method does not take any parameters
Returns
Return Type:Promise<GetProgramTotalsResponse>
JavaScript
import { accounts } from "@wix/loyalty"; export async function myGetProgramTotalsFunction() { try { const programTotals = await accounts.getProgramTotals(); const currentBalance = programTotals.points.balance; const redeemed = programTotals.points.redeemed; console.log( "Success! ", redeemed, " total points have been redeemed in the life of this program.", ); return programTotals; } catch (error) { console.error(error); } } /* Promise resolves to: * { * "points": { * "balance": 2046, * "earned": 1475, * "adjusted": 571, * "redeemed": 0 * } * } */
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?