Search...
onAccountUpdated( )
An event that triggers when a loyalty account is updated.
Description
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.
Syntax
function wixLoyalty_onAccountUpdated(event: AccountUpdated): void
onAccountUpdated Parameters
NAME
TYPE
DESCRIPTION
event
Optional
AccountUpdated
Returns
This function does not return anything.
Return Type:
void
Was this helpful?
An event that triggers when a loyalty account is updated
Copy Code
1// Place this code in the events.js file2// of your site's Backend section.3// Add the file if it doesn't exist.45export function wixLoyalty_onAccountUpdated(event) {6 const eventId = event.metadata.id;7 const updatedDate = event.entity._updatedDate;89 console.log('Account was last updated on ', updatedDate);10 console.log(event);11}1213/* Full event object:14 * {15 * "metadata": {16 * "id":"e6576ab6-1439-4f20-b698-3b2aa82087c8",17 * "entityId":"f0411f1a-ad5a-4b80-94c2-34350cbf1af7",18 * "eventTime":"2023-01-02T00:45:02.145871Z",19 * "triggeredByAnonymizeRequest":false20 * },21 * "entity": {22 * "_id":"f0411f1a-ad5a-4b80-94c2-34350cbf1af7",23 * "contactId":"8a71f711-f77b-43fe-9e3d-5c243f94b2cd",24 * "points": {25 * "balance":50,26 * "earned":50,27 * "adjusted":0,28 * "redeemed":029 * },30 * "latestTransaction": {31 * "_id":"a313b24c-0a0e-4861-a798-ae48cc9a64ea",32 * "amount":50,33 * "type":"EARN",34 * "description":"Subscribed to newsletter.",35 * "_createdDate":"2022-11-09T14:54:57.349Z",36 * "appId":"553c79f3-5625-4f38-b14b-ef7c0d1e87df",37 * "idempotencyKey":"f33ce6re-cy18-445e-8761-23d9471b8b96"38 * },39 * "rewardAvailable":false,40 * "_createdDate":"2022-11-09T06:44:48.159Z",41 * "_updatedDate":"2023-01-02T00:45:02.091Z",42 * "lastActivityDate":"2022-11-09T14:54:57.349Z",43 * "revision":"1226"44 * }45 * }46 */