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:
This function requires elevated permissions and runs only on the backend and on dashboard pages.
function setDefaultLocation(_id: string): Promise<SetDefaultLocationResponse>;
ID of the location to set as the default location.
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"
* }
* }
*/
There are 2 errors with this status code.
This method may also return standard errors. Learn more about standard Wix errors.