Search...
onLocationUpdated( )
Developer Preview
Triggered when a location is updated.
Description
This event is triggered only in cases in which a location's writable properties are updated. Therefore, it is not triggered when a location is archived or set as the default location.
Syntax
function onLocationUpdated(event: LocationUpdated): void
onLocationUpdated Parameters
NAME
TYPE
DESCRIPTION
event
Optional
LocationUpdated
Contains information about the updated 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 created
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 wixLocations_onLocationCreated(event) {6 const timeOfUpdate = event.metadata.eventTime;7 const updatedLocationName = event.entity.name;89 console.log(`${updatedLocationName} was updated at ${timeOfUpdate}. Event details:`, event)10}1112/* Full event object:13 * {14 * "entity": {15 * "_id": "6c8ea272-6538-4787-b2e8-9e1e9fb40990",16 * "address": {17 * "city": "Barcelona",18 * "country": "ES",19 * "formatted": "123 Carrer de Gràcia, Barcelona",20 * "location": {21 * "latitude": 41.393349,22 * "longitude": 2.16215423 * },24 * "postalCode": "08008",25 * "streetAddress": {26 * "apt": "",27 * "name": "Carrer de Gràcia",28 * "number": "123"29 * },30 * "subdivision": "ES-CT"31 * },32 * "archived": false,33 * "businessSchedule": {34 * "periods": [35 * {36 * "closeDay": "MONDAY",37 * "closeTime": "18:00",38 * "openDay": "MONDAY",39 * "openTime": "08:00"40 * },41 * {42 * "closeDay": "TUESDAY",43 * "closeTime": "18:00",44 * "openDay": "TUESDAY",45 * "openTime": "08:00"46 * },47 * {48 * "closeDay": "WEDNESDAY",49 * "closeTime": "18:00",50 * "openDay": "WEDNESDAY",51 * "openTime": "08:00"52 * },53 * {54 * "closeDay": "THURSDAY",55 * "closeTime": "18:00",56 * "openDay": "THURSDAY",57 * "openTime": "08:00"58 * },59 * {60 * "closeDay": "FRIDAY",61 * "closeTime": "18:00",62 * "openDay": "FRIDAY",63 * "openTime": "08:00"64 * }65 * ],66 * "specialHourPeriod": [67 * {68 * "comment": "Half price in the lead up to Christmas!",69 * "endDate": "2023-12-24T23:59:00Z",70 * "isClosed": false,71 * "startDate": "2023-12-01T00:00:00Z"72 * }73 * ]74 * },75 * "default": false,76 * "description": "Our location in Barcelona City Center!",77 * "email": "barcelona@example.com",78 * "fax": "011-34-93-8765432",79 * "name": "Barcelona City Center Store",80 * "phone": "011 34 93 876 5432",81 * "revision": "2",82 * "status": "ACTIVE",83 * "timeZone": "Europe/Madrid"84 * },85 * "metadata": {86 * "entityId": "6c8ea272-6538-4787-b2e8-9e1e9fb40990",87 * "eventTime": "2023-11-13T09:18:32.050964Z",88 * "id": "c7f35c35-cdbb-42d2-9bf9-0389d644387e",89 * "triggeredByAnonymizeRequest": false90 * }91 * }92 */