onAccountPointsUpdated( )


An event that triggers when the points of a loyalty account are adjusted, earned, or redeemed.

The onAccountPointsUpdated() event handler runs when the points of a loyalty account are adjusted, earned, or redeemed. The received AccountPointsUpdated object contains information about the loyalty account that was updated.

Note: Backend events don't work when previewing your site.

Method Declaration
Copy
function wixLoyalty_onAccountPointsUpdated(event: AccountPointsUpdated): void;
Method Parameters
eventAccountPointsUpdated
An event that triggered when a the points of a loyalty account is updated
JavaScript
// Place this code in the events.js file // of your site's Backend section. // Add the file if it doesn't exist. export function wixLoyalty_onAccountPointsUpdated(event) { const eventId = event.metadata.id; const accountBalance = event.data.account.points.balance; console.log("Current account balance: ", accountBalance); console.log(event); } /* Full event object: * { * "metadata": { * "id":"447912e4-b460-4eba-9bd2-3c19b64ddce0", * "entityId":"1ab8f49c-a329-4ddc-a31d-814afbb3b565", * "eventTime":"2023-01-18T13:16:53.000613Z", * "triggeredByAnonymizeRequest":false * }, * "data": { * "account": { * "_id":"1ab8f49c-a329-4ddc-a31d-814afbb3b565", * "contactId":"3128dc64-74fc-442f-aa32-e8e871dad141", * "memberId":"3128dc64-74fc-442f-aa32-e8e871dad141", * "points": { * "balance":95, * "earned":45, * "adjusted":50, * "redeemed":0 * }, * "rewardAvailable":true, * "_createdDate":"2022-11-28T11:57:30.722Z", * "_updatedDate":"2023-01-18T13:16:52.982Z", * "lastActivityDate":"2023-01-18T13:16:52.980Z", * "revision":"13", * "tier": { * "_id":"a8a2bc2b-6957-40a6-9f20-a1bfe52d14de", * "_updatedDate":"2023-01-18T13:16:52.980Z", * "points":95 * } * } * } * } */
Errors

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

Did this help?