setDefaultLocation( )


Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

Sets a new default location.

Notes:

  • There can only be one default location per site.
  • The default location can't be archived.
Authentication

This function requires elevated permissions and runs only on the backend and on dashboard pages.

Permissions
Manage Locations
Learn more about app permissions.
Method Declaration
Copy
function setDefaultLocation(_id: string): Promise<SetDefaultLocationResponse>;
Method Parameters
_idstringRequired

ID of the location to set as the default location.

Returns
Return Type:Promise<SetDefaultLocationResponse>
JavaScript
import { locations } from "wix-business-tools.v2"; import { elevate } from "wix-auth"; /* Sample _id value: '0a965e36-4071-4df0-905b-75458817430a' */ export async function changeDefaultLocation(_id) { try { const elevatedSetDefaultLocation = elevate(locations.setDefaultLocation); const myDefaultLocation = await elevatedSetDefaultLocation(_id); console.log("Default location has been changed to:", myDefaultLocation); return myDefaultLocation; } catch (error) { console.error(error); // Handle the error } } /* Promise resolves to: * { * location: { * "_id": "0a965e36-4071-4df0-905b-75458817430a", * "address": { * "streetAddress": { * "apt": "34", * "name": "Musterstraße", * "number": "5" * }, * "city": "Berlin", * "postalCode": "53782" * }, * "archived": false, * "default": true, * "description": "Our brand new store in Germany", * "email": "store@example.com", * "name": "Germany Store", * "phone": "0208 209 9087", * "revision": "2", * "status": "ACTIVE", * "timeZone": "Europe/Berlin" * } * } */
Errors
400Invalid Argument

There are 2 errors with this status code.

This method may also return standard errors. Learn more about standard Wix errors.

Did this help?