Search.../

onLocationSetDefaultLocation( )

Developer Preview

Triggered when a location is set as the default location.

Syntax

function onLocationSetDefaultLocation(event: LocationSetDefaultLocation): void

onLocationSetDefaultLocation Parameters

NAME
TYPE
DESCRIPTION
event
Optional
LocationSetDefaultLocation

Contains information about the new default location and metadata for the event.

Returns

This function does not return anything.

Return Type:

void

Was this helpful?

An event that triggers when a location is set to be the default location

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 wixLocations_onLocationSetDefaultLocation(event) {
6 const changeOfDefaultTime = event.metadata.eventTime;
7 const oldDefault = event.data.prevDefaultLocationId;
8 const newDefault = event.data.currDefaultLocationId;
9
10 console.log(`Default location has been changed from location with id ${oldDefault} to location with id ${newDefault}. The change took place at ${changeOfDefaultTime}. Event details:`, event)
11}
12
13/* Full event object:
14 * {
15 * "metadata": {
16 * "entityId":"a636dae4-fdc9-4da8-9eef-7b0d23b34f22",
17 * "eventTime":"2023-11-13T09:01:28.564399Z",
18 * "id": "4d896c67-74f0-4103-86bd-db7b0cbded81",
19 * "triggeredByAnonymizeRequest":false
20 * },
21 * "data": {
22 * "currDefaultLocationId":"a636dae4-fdc9-4da8-9eef-7b0d23b34f22",
23 * "prevDefaultLocationId":"6a7a7356-a122-4de6-943c-3ea9e66f0d0a"
24 * }
25 * }
26*/