Search.../

onAccountCreated( )

An event that triggers when a loyalty account is created.

Description

The onAccountCreated() event handler runs when a loyalty account is created. The received AccountCreated object contains information about the loyalty account that was created.

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

Syntax

function wixLoyalty_onAccountCreated(event: AccountCreated): void

onAccountCreated Parameters

NAME
TYPE
DESCRIPTION
event
Optional
AccountCreated

Returns

This function does not return anything.

Return Type:

void

Was this helpful?

An event that triggers when a loyalty account is created

Copy Code
1// Place this code in the events.js file
2// of your site's Backend section.
3// Add the file if it doesn't exist.
4
5export function wixLoyalty_onAccountCreated(event) {
6 const eventId = event.metadata.id;
7 const contactId = event.entity.contactId;
8 const createdDate = event.entity._createdDate;
9
10 console.log('Account was created on ', createdDate);
11 console.log(event);
12}
13
14/* Full event object:
15 * {
16 * "account": {
17 * "_id": "c81d5126-20bc-4f29-ad4e-b1680a9736c5",
18 * "contactId": "3e0acda0-98b6-4f75-b8e9-3be7d4258891",
19 * "points": {
20 * "balance": 0,
21 * "earned": 0,
22 * "adjusted": 0,
23 * "redeemed": 0
24 * },
25 * "rewardAvailable": false,
26 * "_createdDate": "2023-01-02T00:51:12.894Z",
27 * "_updatedDate": "2023-01-02T00:51:12.894Z",
28 * "lastActivityDate": "2023-01-02T00:51:12.894Z",
29 * "revision": "1"
30 * }
31 * }
32 */