> Portal Navigation: > > - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version. > - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages). > - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`). > - Top-level index of all portals: https://dev.wix.com/docs/llms.txt > - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt # UpdateLocation # Package: locations # Namespace: LocationsService # Method link: https://dev.wix.com/docs/api-reference/business-management/locations/update-location.md ## Permission Scopes: Manage Locations: SCOPE.DC-MULTILOCATION.MANAGE-LOCATIONS ## Introduction Overrides an existing location. > **Note:** Currently, it isn't possible to partially update a location. Therefore, you'll need to pass the full location object in the body of the call. --- ## REST API ### Schema ``` Method: updateLocation Description: Overrides an existing location. > **Note:** Currently, it isn't possible to partially update a location. Therefore, you'll need to pass the full location object in the body of the call. URL: https://www.wixapis.com/locations/v1/locations/{location.id} Method: PUT # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present. Required parameters: location, location.id, location.name, location.address, location.timeZone Method parameters: param name: location | type: Location | required: true - name: id | type: string | description: Location GUID. | required: true - name: name | type: string | description: Location name. | required: true - name: description | type: string | description: Location description. - name: status | type: LocationStatus | description: Location status. Defaults to `ACTIVE`. __Notes:__ - [Archiving a location](https://dev.wix.com/api/rest/business-info/locations/archive-location) doesn't affect the location's status. - `INACTIVE` status is currently not supported. - enum: ACTIVE, INACTIVE - name: fax | type: string | description: Fax number. - name: timeZone | type: string | description: Timezone in `America/New_York` format. | required: true - name: email | type: string | description: Email address. - name: phone | type: string | description: Phone number. - name: address | type: Address | description: Address. | required: true - name: country | type: string | description: 2-letter country code in an [ISO-3166 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) format. - name: subdivision | type: string | description: Code for a subdivision (such as state, prefecture, or province) in [ISO 3166-2](https://en.wikipedia.org/wiki/ISO_3166-2) format. - name: city | type: string | description: City name. - name: postalCode | type: string | description: Postal or zip code. - name: streetAddress | type: StreetAddress | description: Street address. Includes street name, number, and apartment number in separate fields. - name: number | type: string | description: Street number. - name: name | type: string | description: Street name. - name: apt | type: string | description: Apartment number. - name: formattedAddress | type: string | description: Full address of the location. - name: hint | type: string | description: Extra information that helps finding the location. - name: geocode | type: AddressLocation | description: Geographic coordinates of location. - name: latitude | type: number | description: Latitude of the location. Must be between -90 and 90. - name: longitude | type: number | description: Longitude of the location. Must be between -180 and 180. - name: businessSchedule | type: BusinessSchedule | description: Business schedule. Array of weekly recurring time periods when the location is open for business. Limited to 100 time periods. __Note:__ Not supported by Wix Bookings. - name: periods | type: array | description: Weekly recurring time periods when the business is regularly open or the service is available. Limited to 100 time periods. - name: openDay | type: DayOfWeek | description: Day of the week the period starts on. - enum: MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY - name: openTime | type: string | description: Time the period starts in 24-hour [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) extended format. Valid values are `00:00` to `24:00`, where `24:00` represents midnight at the end of the specified day. - name: closeDay | type: DayOfWeek | description: Day of the week the period ends on. - name: closeTime | type: string | description: Time the period ends in 24-hour [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) extended format. Valid values are `00:00` to `24:00`, where `24:00` represents midnight at the end of the specified day. __Note:__ If `openDay` and `closeDay` specify the same day of the week `closeTime` must be later than `openTime`. - name: specialHourPeriod | type: array | description: Exceptions to the business's regular hours. The business can be open or closed during the exception. - name: startDate | type: string | description: Start date and time of the exception in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format and [Coordinated Universal Time (UTC)](https://en.wikipedia.org/wiki/Coordinated_Universal_Time). - name: endDate | type: string | description: End date and time of the exception in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format and [Coordinated Universal Time (UTC)](https://en.wikipedia.org/wiki/Coordinated_Universal_Time). - name: isClosed | type: boolean | description: Whether the business is closed (or the service is not available) during the exception. Default: `true`. - name: comment | type: string | description: Additional info about the exception. For example, "We close earlier on New Year's Eve." - name: revision | type: string | description: Revision number, which increments by 1 each time the location is updated. To prevent conflicting changes, the existing revision must be used when updating a location. - name: locationTypes | type: array | description: Location types. - enum: UNKNOWN, BRANCH, OFFICES, RECEPTION, HEADQUARTERS, INVENTORY - name: extendedFields | type: ExtendedFields | description: Extended fields for data extensions. - name: namespaces | type: object | description: Extended field data. Each key corresponds to the namespace of the app that created the extended fields. The value of each key is structured according to the schema defined when the extended fields were configured. You can only access fields for which you have the appropriate permissions. Learn more about [extended fields](https://dev.wix.com/docs/rest/articles/getting-started/extended-fields.md). Return type: UpdateLocationResponse - name: location | type: Location | description: Updated location. - name: id | type: string | description: Location GUID. - name: name | type: string | description: Location name. - name: description | type: string | description: Location description. - name: default | type: boolean | description: Whether this is the default location. There can only be one default location per site. The default location can't be archived. - name: status | type: LocationStatus | description: Location status. Defaults to `ACTIVE`. __Notes:__ - [Archiving a location](https://dev.wix.com/api/rest/business-info/locations/archive-location) doesn't affect the location's status. - `INACTIVE` status is currently not supported. - enum: ACTIVE, INACTIVE - name: fax | type: string | description: Fax number. - name: timeZone | type: string | description: Timezone in `America/New_York` format. - name: email | type: string | description: Email address. - name: phone | type: string | description: Phone number. - name: address | type: Address | description: Address. - name: country | type: string | description: 2-letter country code in an [ISO-3166 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) format. - name: subdivision | type: string | description: Code for a subdivision (such as state, prefecture, or province) in [ISO 3166-2](https://en.wikipedia.org/wiki/ISO_3166-2) format. - name: city | type: string | description: City name. - name: postalCode | type: string | description: Postal or zip code. - name: streetAddress | type: StreetAddress | description: Street address. Includes street name, number, and apartment number in separate fields. - name: number | type: string | description: Street number. - name: name | type: string | description: Street name. - name: apt | type: string | description: Apartment number. - name: formattedAddress | type: string | description: Full address of the location. - name: hint | type: string | description: Extra information that helps finding the location. - name: geocode | type: AddressLocation | description: Geographic coordinates of location. - name: latitude | type: number | description: Latitude of the location. Must be between -90 and 90. - name: longitude | type: number | description: Longitude of the location. Must be between -180 and 180. - name: businessSchedule | type: BusinessSchedule | description: Business schedule. Array of weekly recurring time periods when the location is open for business. Limited to 100 time periods. __Note:__ Not supported by Wix Bookings. - name: periods | type: array | description: Weekly recurring time periods when the business is regularly open or the service is available. Limited to 100 time periods. - name: openDay | type: DayOfWeek | description: Day of the week the period starts on. - enum: MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY - name: openTime | type: string | description: Time the period starts in 24-hour [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) extended format. Valid values are `00:00` to `24:00`, where `24:00` represents midnight at the end of the specified day. - name: closeDay | type: DayOfWeek | description: Day of the week the period ends on. - name: closeTime | type: string | description: Time the period ends in 24-hour [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) extended format. Valid values are `00:00` to `24:00`, where `24:00` represents midnight at the end of the specified day. __Note:__ If `openDay` and `closeDay` specify the same day of the week `closeTime` must be later than `openTime`. - name: specialHourPeriod | type: array | description: Exceptions to the business's regular hours. The business can be open or closed during the exception. - name: startDate | type: string | description: Start date and time of the exception in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format and [Coordinated Universal Time (UTC)](https://en.wikipedia.org/wiki/Coordinated_Universal_Time). - name: endDate | type: string | description: End date and time of the exception in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format and [Coordinated Universal Time (UTC)](https://en.wikipedia.org/wiki/Coordinated_Universal_Time). - name: isClosed | type: boolean | description: Whether the business is closed (or the service is not available) during the exception. Default: `true`. - name: comment | type: string | description: Additional info about the exception. For example, "We close earlier on New Year's Eve." - name: revision | type: string | description: Revision number, which increments by 1 each time the location is updated. To prevent conflicting changes, the existing revision must be used when updating a location. - name: archived | type: boolean | description: Whether the location is archived. Archived locations can't be updated. __Note:__ [Archiving a location](https://dev.wix.com/api/rest/business-info/locations/archive-location) doesn't affect its `status`. - name: locationTypes | type: array | description: Location types. - enum: UNKNOWN, BRANCH, OFFICES, RECEPTION, HEADQUARTERS, INVENTORY - name: extendedFields | type: ExtendedFields | description: Extended fields for data extensions. - name: namespaces | type: object | description: Extended field data. Each key corresponds to the namespace of the app that created the extended fields. The value of each key is structured according to the schema defined when the extended fields were configured. You can only access fields for which you have the appropriate permissions. Learn more about [extended fields](https://dev.wix.com/docs/rest/articles/getting-started/extended-fields.md). Possible Errors: HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: CANNOT_ARCHIVE_DEFAULT | Description: Can't archive the default location. HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: CANNOT_PERFORM_ACTION_ON_ARCHIVED_LOCATION | Description: Can't perform this action on an archived location. HTTP Code: 404 | Status Code: NOT_FOUND | Application Code: LOCATION_NOT_FOUND | Description: Couldn't find the location. ``` ### Examples ### Update Location ```curl curl -X PUT \ 'https://www.wixapis.com/locations/v1/locations/ea50573e-35fa-47ca-bba7-3e45a935d9bc' \ -H 'Content-Type: application/json' \ -H 'Authorization: ' \ --data-binary '{ "location": { "id":"ea50573e-35fa-47ca-bba7-3e45a935d9bc", "name":"New Location Name", "default":false, "status":"ACTIVE", "locationType":"UNKNOWN", "timeZone":"America/Los_Angeles", "address":{ "country":"US", "subdivision":"CA", "city":"Los Angeles", "postalCode":"90015", "streetAddress":{ "number":"1111", "name":"South Figueroa Street", "apt":"" }, "formattedAddress":"STAPLES Center, South Figueroa Street, Los Angeles, CA, USA", "geocode":{ "latitude":34.0430175, "longitude":-118.2672541 } }, "revision":"4", "archived":false } }' ``` --- ## JavaScript SDK ### Schema ``` Method: wixClientAdmin.locations.LocationsService.updateLocation(_id, location) Description: Overrides an existing location. > **Note:** Currently, it isn't possible to partially update a location. Therefore, you'll need to pass the full location object in the body of the call. # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present. Required parameters: location, _id, location.name, location.address, location.timeZone Method parameters: param name: _id | type: string | description: Location GUID. | required: true param name: location | type: Location | required: true - name: name | type: string | description: Location name. | required: true - name: description | type: string | description: Location description. - name: status | type: LocationStatus | description: Location status. Defaults to `ACTIVE`. __Notes:__ - [Archiving a location](https://dev.wix.com/api/rest/business-info/locations/archive-location) doesn't affect the location's status. - `INACTIVE` status is currently not supported. - enum: ACTIVE, INACTIVE - name: fax | type: string | description: Fax number. - name: timeZone | type: string | description: Timezone in `America/New_York` format. | required: true - name: email | type: string | description: Email address. - name: phone | type: string | description: Phone number. - name: address | type: Address | description: Address. | required: true - name: streetAddress | type: StreetAddress | description: none - name: name | type: string | description: none - name: number | type: string | description: none - name: city | type: string | description: none - name: subdivision | type: string | description: none - name: country | type: string | description: none - name: postalCode | type: string | description: none - name: businessSchedule | type: BusinessSchedule | description: Business schedule. Array of weekly recurring time periods when the location is open for business. Limited to 100 time periods. __Note:__ Not supported by Wix Bookings. - name: periods | type: array | description: Weekly recurring time periods when the business is regularly open or the service is available. Limited to 100 time periods. - name: openDay | type: DayOfWeek | description: Day of the week the period starts on. - enum: MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY - name: openTime | type: string | description: Time the period starts in 24-hour [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) extended format. Valid values are `00:00` to `24:00`, where `24:00` represents midnight at the end of the specified day. - name: closeDay | type: DayOfWeek | description: Day of the week the period ends on. - name: closeTime | type: string | description: Time the period ends in 24-hour [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) extended format. Valid values are `00:00` to `24:00`, where `24:00` represents midnight at the end of the specified day. __Note:__ If `openDay` and `closeDay` specify the same day of the week `closeTime` must be later than `openTime`. - name: specialHourPeriod | type: array | description: Exceptions to the business's regular hours. The business can be open or closed during the exception. - name: startDate | type: string | description: Start date and time of the exception in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format and [Coordinated Universal Time (UTC)](https://en.wikipedia.org/wiki/Coordinated_Universal_Time). - name: endDate | type: string | description: End date and time of the exception in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format and [Coordinated Universal Time (UTC)](https://en.wikipedia.org/wiki/Coordinated_Universal_Time). - name: isClosed | type: boolean | description: Whether the business is closed (or the service is not available) during the exception. Default: `true`. - name: comment | type: string | description: Additional info about the exception. For example, "We close earlier on New Year's Eve." - name: revision | type: string | description: Revision number, which increments by 1 each time the location is updated. To prevent conflicting changes, the existing revision must be used when updating a location. - name: locationTypes | type: array | description: Location types. - enum: UNKNOWN, BRANCH, OFFICES, RECEPTION, HEADQUARTERS, INVENTORY - name: extendedFields | type: ExtendedFields | description: Extended fields for data extensions. - name: namespaces | type: object | description: Extended field data. Each key corresponds to the namespace of the app that created the extended fields. The value of each key is structured according to the schema defined when the extended fields were configured. You can only access fields for which you have the appropriate permissions. Learn more about [extended fields](https://dev.wix.com/docs/rest/articles/getting-started/extended-fields.md). Return type: PROMISE - name: _id | type: string | description: Location GUID. - name: name | type: string | description: Location name. - name: description | type: string | description: Location description. - name: default | type: boolean | description: Whether this is the default location. There can only be one default location per site. The default location can't be archived. - name: status | type: LocationStatus | description: Location status. Defaults to `ACTIVE`. __Notes:__ - [Archiving a location](https://dev.wix.com/api/rest/business-info/locations/archive-location) doesn't affect the location's status. - `INACTIVE` status is currently not supported. - enum: ACTIVE, INACTIVE - name: fax | type: string | description: Fax number. - name: timeZone | type: string | description: Timezone in `America/New_York` format. - name: email | type: string | description: Email address. - name: phone | type: string | description: Phone number. - name: address | type: Address | description: Address. - name: streetAddress | type: StreetAddress | description: none - name: name | type: string | description: none - name: number | type: string | description: none - name: city | type: string | description: none - name: subdivision | type: string | description: none - name: country | type: string | description: none - name: postalCode | type: string | description: none - name: businessSchedule | type: BusinessSchedule | description: Business schedule. Array of weekly recurring time periods when the location is open for business. Limited to 100 time periods. __Note:__ Not supported by Wix Bookings. - name: periods | type: array | description: Weekly recurring time periods when the business is regularly open or the service is available. Limited to 100 time periods. - name: openDay | type: DayOfWeek | description: Day of the week the period starts on. - enum: MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY - name: openTime | type: string | description: Time the period starts in 24-hour [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) extended format. Valid values are `00:00` to `24:00`, where `24:00` represents midnight at the end of the specified day. - name: closeDay | type: DayOfWeek | description: Day of the week the period ends on. - name: closeTime | type: string | description: Time the period ends in 24-hour [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) extended format. Valid values are `00:00` to `24:00`, where `24:00` represents midnight at the end of the specified day. __Note:__ If `openDay` and `closeDay` specify the same day of the week `closeTime` must be later than `openTime`. - name: specialHourPeriod | type: array | description: Exceptions to the business's regular hours. The business can be open or closed during the exception. - name: startDate | type: string | description: Start date and time of the exception in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format and [Coordinated Universal Time (UTC)](https://en.wikipedia.org/wiki/Coordinated_Universal_Time). - name: endDate | type: string | description: End date and time of the exception in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format and [Coordinated Universal Time (UTC)](https://en.wikipedia.org/wiki/Coordinated_Universal_Time). - name: isClosed | type: boolean | description: Whether the business is closed (or the service is not available) during the exception. Default: `true`. - name: comment | type: string | description: Additional info about the exception. For example, "We close earlier on New Year's Eve." - name: revision | type: string | description: Revision number, which increments by 1 each time the location is updated. To prevent conflicting changes, the existing revision must be used when updating a location. - name: archived | type: boolean | description: Whether the location is archived. Archived locations can't be updated. __Note:__ [Archiving a location](https://dev.wix.com/api/rest/business-info/locations/archive-location) doesn't affect its `status`. - name: locationTypes | type: array | description: Location types. - enum: UNKNOWN, BRANCH, OFFICES, RECEPTION, HEADQUARTERS, INVENTORY - name: extendedFields | type: ExtendedFields | description: Extended fields for data extensions. - name: namespaces | type: object | description: Extended field data. Each key corresponds to the namespace of the app that created the extended fields. The value of each key is structured according to the schema defined when the extended fields were configured. You can only access fields for which you have the appropriate permissions. Learn more about [extended fields](https://dev.wix.com/docs/rest/articles/getting-started/extended-fields.md). Possible Errors: HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: CANNOT_ARCHIVE_DEFAULT | Description: Can't archive the default location. HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: CANNOT_PERFORM_ACTION_ON_ARCHIVED_LOCATION | Description: Can't perform this action on an archived location. HTTP Code: 404 | Status Code: NOT_FOUND | Application Code: LOCATION_NOT_FOUND | Description: Couldn't find the location. ``` ### Examples ### Update a location's details ```javascript import { locations } from '@wix/business-tools'; export async function myUpdateLocationFunction(location) { try { const updatedLocation = await locations.updateLocation(location); console.log('Location details have been successfully updated:', updatedLocation); return updatedLocation; } catch (error) { console.error(error); // Handle the error } } ``` ### Partially update a location's data without overwriting other properties (with $w) This code shows an example of the user using an input form to change just a couple ofa location's properties - phone and email - while avoiding overwriting the other properties with a null value. This page is accessible to only company managers so they can update locations in the database. ```javascript /******************************************** * Backend code - update-location.web.js/ts * *******************************************/ import { Permissions, webMethod } from '@wix/web-methods'; import { locations } from '@wix/business-tools'; import { auth } from '@wix/essentials'; export const updateLocation = webMethod(Permissions.Anyone, async (locationId, location) => { try { const elevatedUpdateLocation = auth.elevate(locations.updateLocation); const updatedLocation = await elevatedUpdateLocation(locationId, location); return updatedLocation; } catch (error) { console.error(error); throw new Error(error); } }); export const listLocations = webMethod(Permissions.Anyone, async () => { try { const elevatedListLocations = auth.elevate(locations.listLocations); const results = await elevatedListLocations(); return results.locations; } catch (error) { console.error(error); throw new Error(error); } }); export const getLocationById = webMethod(Permissions.Anyone, async (locationId) => { try { const elevatedGetLocation = auth.elevate(locations.getLocation); const myLocation = await elevatedGetLocation(locationId); return myLocation; } catch (error) { console.error(error); throw new Error(error); } }); /************* * Page code * ************/ import { updateLocation, listLocations, getLocationById } from 'backend/update-location.web'; $w.onReady(async () => { await populateStoresDropdown(); $w('#update').onClick(async () => { // set location to current value and only change relevant properties' values const locationId = $w('#locationsDropdown').value; const location = await getLocationById(locationId); location.email = $w('#email').value; location.phone = $w('#phone').value; const updatedLocation = await updateLocation(locationId, location); console.log('Location details have been successfully updated to the following:\n', updatedLocation); $w('#updateSuccessMsg').show(); }); }); async function populateStoresDropdown() { const locations = await listLocations(); const dropdownOptions = locations.map((location) => { return { label: location.name, value: location._id }; }); $w('#locationsDropdown').options = dropdownOptions; } ``` ### Overwrite a location's data (with $w) This code uses the user's input into a form on the page to overwrite the data of a location which they choose from a dropdown list on the page. To make this accessible to only company managers so they can update locations in the database, make a members-only page. ```javascript /******************************************** * Backend code - update-location.web.js/ts * *******************************************/ import { Permissions, webMethod } from '@wix/web-methods'; import { locations } from '@wix/business-tools'; import { auth } from '@wix/essentials'; export const updateLocation = webMethod(Permissions.Anyone, async (locationId, location) => { try { const elevatedUpdateLocation = auth.elevate(locations.updateLocation); const updatedLocation = await elevatedUpdateLocation(locationId, location); return updatedLocation; } catch (error) { console.error(error); throw new Error(error); } }); export const listLocations = webMethod(Permissions.Anyone, async () => { try { const elevatedListLocations = auth.elevate(locations.listLocations); const results = await elevatedListLocations(); return results.locations; } catch (error) { console.error(error); throw new Error(error); } }); export const getLocationById = webMethod(Permissions.Anyone, async (locationId) => { try { const elevatedGetLocation = auth.elevate(locations.getLocation); const myLocation = await elevatedGetLocation(locationId); return myLocation; } catch (error) { console.error(error); throw new Error(error); } }); /************* * Page code * ************/ import { updateLocation, listLocations, getLocationById } from 'backend/update-location.web'; $w.onReady(async () => { await populateStoresDropdown(); $w('#update').onClick(async () => { const locationId = $w('#locationsDropdown').value; const currentLocationValues = await getLocationById(locationId); const location = { name: $w('#newName').value, address: { streetAddress: { number: $w('#streetNumber').value, name: $w('#streetName').value }, city: $w('#city').value, postalCode: $w('#postalCode').value, }, timeZone: $w('#timeZone').value, description: $w('#description').value, email: $w('#email').value, phone: $w('#phone').value, // Must use the current revision value revision: currentLocationValues.revision }; const updatedLocation = await updateLocation(locationId, location); console.log('Location details have been successfully updated to the following:\n', updatedLocation); $w('#updateSuccessMsg').show(); }); }); async function populateStoresDropdown() { const locations = await listLocations(); const dropdownOptions = locations.map((location) => { return { label: location.name, value: location._id }; }); $w('#locationsDropdown').options = dropdownOptions; }; ``` ### Update a location's details (with elevated permissions) ```javascript import { locations } from '@wix/business-tools'; import { auth } from '@wix/essentials'; /* Sample _id value: '4ae3bbc8-fb78-4eb7-8bc5-1fec19c7dbfc' * * Sample location value: * { * address: { * city: 'Roma', * country: 'IT', * formatted: 'Via Roma 123, 00100 Roma', * location: { * latitude: 41.9028, * longitude: 12.4964 * }, * postalCode: '00100', * streetAddress: { * apt: '', * name: 'Via Roma', * number: '123' * }, * subdivision: 'IT-RM' * }, * businessSchedule: { * periods: [ * { * closeDay: 'SATURDAY', * closeTime: '24:00', * openDay: 'MONDAY', * openTime: '00: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' * } * ] * }, * description: 'Our store in Rome is open 24/6!', * email: '24.6.rome@example.com', * fax: '+39 06 1234 5679', * name: 'Rome 24/6', * phone: '+39 06 1234 5678', * status: 'ACTIVE', * timeZone: 'Europe/Rome' * } */ export async function myUpdateLocationFunction(location) { try { const elevatedUpdateLocation = auth.elevate(locations.updateLocation); const updatedLocation = await elevatedUpdateLocation(location); console.log('Location details have been successfully updated:', updatedLocation); return updatedLocation; } catch (error) { console.error(error); // Handle the error } } /* Promise resolves to: * { * "_id": "4ae3bbc8-fb78-4eb7-8bc5-1fec19c7dbfc" * "address": { * "city": "Roma", * "country": "IT", * "formatted": "Via Roma 123, 00100 Roma", * "location": { * "latitude": 41.9028, * "longitude": 12.4964 * }, * "postalCode": "00100", * "streetAddress": { * "apt": "", * "name": "Via Roma", * "number": "123" * }, * "subdivision": 'IT-RM' * }, * "archived": false, * "businessSchedule": { * "periods": [ * { * "closeDay": "MONDAY", * "closeTime": "00:00", * "openDay": "SATURDAY", * "openTime": "24: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 store in Rome is open 24/6!", * "email": "24.6.rome@example.com", * "fax": "+39 06 1234 5679", * "name": "Rome 24/6", * "phone": "+39 06 1234 5678", * "revision": "2", * "status": "ACTIVE", * "timeZone": "Europe/Rome" * } */ ``` ### updateLocation (self-hosted) Self-hosted SDK calls require you to [create a client](https://dev.wix.com/docs/sdk/articles/work-with-the-sdk/about-the-wix-client.md). ```javascript import { createClient } from '@wix/sdk'; import { locations } from '@wix/business-tools'; // Import the auth strategy for the relevant access type // Import the relevant host module if needed const myWixClient = createClient ({ modules: { locations }, // Include the auth strategy and host as relevant }); async function updateLocation(_id,location) { const response = await myWixClient.locations.updateLocation(_id,location); }; ``` ---