An event that triggers when a loyalty program is updated.
The onProgramUpdated()
event handler runs when the name or the point definition of the loyalty program is updated. The received ProgramUpdated
object contains information about the program that was updated.
onProgramUpdated()
does not trigger when the loyalty program's status changes.
Note: Backend events don't work when previewing your site.
function wixLoyalty_onProgramUpdated(event: ProgramUpdated): void;
Information about the loyalty program that was updated and metadata for the event.
// 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_onProgramUpdated(event) {
const eventId = event.metadata.id;
const programName = event.entity.name;
const updatedDate = event.entity._updatedDate;
console.log("Program last updated: ", updatedDate);
console.log(event);
}
/* Full event object:
* {
* "metadata": {
* "id":"bc647d5a-0d2c-46db-b241-8eb82c431e86",
* "entityId":"settings",
* "eventTime":"2022-11-09T07:58:42.945654Z",
* "triggeredByAnonymizeRequest":false
* },
* "entity": {
* "name":"Frequent Flower Program",
* "pointDefinition": {
* "customName":"Petals",
* "icon":"shapes/8de38e8fe76f4e9f937ae23e9ba1eb04.svg"
* },
* "status":"ACTIVE",
* "_createdDate":"2022-11-07T15:26:12.798Z",
* "_updatedDate":"2022-11-09T07:58:42.936Z"
* }
* }
*/
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.