This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.
Triggered when a location is created.
function wixLocations_onLocationCreated(event: LocationCreated): void;
Contains information about the created location 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 wixLocations_onLocationCreated(event) {
const createdTime = event.metadata.eventTime;
console.log(`Location was created at ${createdTime}. Event details:`, event);
}
/* Full event object:
* {
* "entity": {
* "_id": "a636dae4-fdc9-4da8-9eef-7b0d23b34f22",
* "address": {
* "city": "São Paulo",
* "country": "BR",
* "formatted": "123 Avenida Paulista, São Paulo",
* "location": {
* "latitude": -23.561722,
* "longitude": -46.655275
* },
* "postalCode": "01311-000"
* "streetAddress": {
* "apt": ""
* "name": "Avenida Paulista",
* "number": "123",
* },
* "subdivision": "BR-SP",
* },
* "archived": false,
* "businessSchedule": {
* "periods": [
* {
* "closeDay": "MONDAY",
* "closeTime": "18:00",
* "openDay": "MONDAY",
* "openTime": "08:00"
* },
* {
* "closeDay": "TUESDAY",
* "closeTime": "18:00",
* "openDay": "TUESDAY",
* "openTime": "08:00"
* },
* {
* "closeDay": "WEDNESDAY",
* "closeTime": "18:00",
* "openDay": "WEDNESDAY",
* "openTime": "08:00"
* },
* {
* "closeDay": "THURSDAY",
* "closeTime": "18:00",
* "openDay": "THURSDAY",
* "openTime": "08:00"
* },
* {
* "closeDay": "FRIDAY",
* "closeTime": "18:00",
* "openDay": "FRIDAY",
* "openTime": "08:00"
* }
* ],
* "specialHourPeriod": [
* {
* "comment": "Half price in the lead up to Christmas!",
* "endDate": "2023-12-24T23:59:00Z",
* "isClosed": false,
* "startDate": "2023-12-01T00:00:00Z"
* }
* ]
* },
* "default": false,
* "description": "Our location in São Paulo City Center!",
* "email": "saopaulo@example.com",
* "fax": "011-55-11-987654321",
* "name": "São Paulo City Center Store",
* "phone": "011 98765 4321",
* "revision": "1",
* "status": "ACTIVE",
* "timeZone": "America/Sao_Paulo",
* },
* "metadata": {
* "entityId": "a636dae4-fdc9-4da8-9eef-7b0d23b34f22",
* "eventTime": "2023-11-13T08:22:25.392520Z",
* "id": "a41b6434-982d-413d-8ce0-ac4dd8d3dc00",
* "triggeredByAnonymizeRequest": false
* }
* }
*/
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.