An event that triggers when a loyalty account is updated.
The onAccountUpdated()
event handler runs when a loyalty account is updated. The received AccountUpdated
object contains information about the loyalty account that was updated.
The event also runs every 15 minutes when loyalty points are recalculated.
Note: Backend events don't work when previewing your site.
function wixLoyalty_onAccountUpdated(event: AccountUpdated): void;
// 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_onAccountUpdated(event) {
const eventId = event.metadata.id;
const updatedDate = event.entity._updatedDate;
console.log("Account was last updated on ", updatedDate);
console.log(event);
}
/* Full event object:
* {
* "metadata": {
* "id":"e6576ab6-1439-4f20-b698-3b2aa82087c8",
* "entityId":"f0411f1a-ad5a-4b80-94c2-34350cbf1af7",
* "eventTime":"2023-01-02T00:45:02.145871Z",
* "triggeredByAnonymizeRequest":false
* },
* "entity": {
* "_id":"f0411f1a-ad5a-4b80-94c2-34350cbf1af7",
* "contactId":"8a71f711-f77b-43fe-9e3d-5c243f94b2cd",
* "points": {
* "balance":50,
* "earned":50,
* "adjusted":0,
* "redeemed":0
* },
* "rewardAvailable":false,
* "_createdDate":"2022-11-09T06:44:48.159Z",
* "_updatedDate":"2023-01-02T00:45:02.091Z",
* "lastActivityDate":"2022-11-09T14:54:57.349Z",
* "revision":"1226"
* }
* }
*/
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.