Search.../

getSiteProperties( )

Developer Preview

Retrieves site properties

Description

The getSiteProperties() function returns a promise that resolves to the site properties.

Admin Method

This function requires elevated permissions to run. This function is not universal and runs only on the backend.

Syntax

function getSiteProperties(options: GetSitePropertiesOptions): Promise<PropertiesReadResponse>

getSiteProperties Parameters

NAME
TYPE
DESCRIPTION
options
Optional
GetSitePropertiesOptions

Field options.

Returns

The resulting properties for the requested site.

Return Type:

Promise<
PropertiesReadResponse
>
NAME
TYPE
DESCRIPTION
properties
Properties

Properties for the requested site.

version
string

Current version of the stored property site. For internal use.

Was this helpful?

Get Site Properties (dashboard page code)
This example uses elevate(), which enables site visitors to call functions without the required permissions. Exercise caution when using elevate() to prevent security vulnerabilities.

Copy Code
1import { siteProperties } from 'wix-business-tools.v2';
2import { elevate } from 'wix-auth';
3
4export async function myGetSitePropertiesFunction() {
5 try {
6 const elevatedGetSiteProperties = elevate(siteProperties.getSiteProperties);
7 const mySiteProperties = await elevatedGetSiteProperties();
8
9 console.log('Success! Site properties:', mySiteProperties);
10 return mySiteProperties;
11 } catch (error) {
12 console.error(error);
13 // Handle the error
14 }
15}
16
17/* Promise resolves to:
18 * {
19 * "properties": {
20 * "address": {
21 * "apartmentNumber": "",
22 * "city": "Radlett",
23 * "coordinates": {
24 * "latitude": 51.6855755,
25 * "longitude": -0.3241171999999999
26 * }
27 * "country": "GB",
28 * "googleFormattedAddress": "10 Watford Road, Radlett, UK",
29 * "hint": {
30 * "placement": "BEFORE",
31 * "text": "Located on the ground floor"
32 * },
33 * "isPhysical": true,
34 * "state": "Greater London",
35 * "street": "Watford Road",
36 * "streetNumber": "10",
37 * "zip": "WD7 8LD",
38 * },
39 * "businessConfig": "UNKNOWN",
40 * "businessName": "Kids Clothes For You",
41 * "businessSchedule": {
42 * "periods": [
43 * {
44 * "closeDay": "MONDAY",
45 * "closeTime": "18:00",
46 * "openDay": "MONDAY",
47 * "openTime": "08:00"
48 * },
49 * {
50 * "closeDay": "TUESDAY",
51 * "closeTime": "18:00",
52 * "openDay": "TUESDAY",
53 * "openTime": "08:00"
54 * },
55 * {
56 * "closeDay": "WEDNESDAY",
57 * "closeTime": "18:00",
58 * "openDay": "WEDNESDAY",
59 * "openTime": "08:00"
60 * },
61 * {
62 * "closeDay": "THURSDAY",
63 * "closeTime": "18:00",
64 * "openDay": "THURSDAY",
65 * "openTime": "08:00"
66 * },
67 * {
68 * "closeDay": "FRIDAY",
69 * "closeTime": "18:00",
70 * "openDay": "FRIDAY",
71 * "openTime": "08:00"
72 * }
73 * ],
74 * "specialHourPeriod": [
75 * {
76 * "comment": "Half price in the lead up to Christmas!",
77 * "endDate": "2023-12-24T23:59:00Z",
78 * "isClosed": false,
79 * "startDate": "2023-12-01T00:00:00Z"
80 * }
81 * ]
82 * },
83 * "categories": {
84 * "businessTermId": "38194ba8-1218-431c-a007-09c26c75ee0d"
85 * "primary": "other",
86 * "secondary": [
87 * "Local Business"
88 * ],
89 * },
90 * "consentPolicy": {
91 * "advertising": true,
92 * "analytics": true,
93 * "dataToThirdParty": true,
94 * "essential": true,
95 * "functional": true
96 * },
97 * "description": "Clothes for little people, for a little price!",
98 * "email": "kidsclothes@example.com",
99 * "fax": "011-44-20-12345678",
100 * "language": "en",
101 * "locale": {
102 * "languageCode": "en",
103 * "country": "GB"
104 * },
105 * "logo": "a8a52b_bf5596e614d8484e9f1d429ac256e1ad~mv2.jpeg",
106 * "paymentCurrency": "GBP",
107 * "phone": "0208 123 4569",
108 * "siteDisplayName": "Business Tools",
109 * "timeZone": "Europe/London",
110 * "trackClicksAnalytics": false
111 * },
112 * "version": "60"
113 * }
114 */
115
Get Site Properties (export from backend code)
This example uses elevate(), which enables site visitors to call functions without the required permissions. Exercise caution when using elevate() to prevent security vulnerabilities.

Copy Code
1import { Permissions, webMethod } from 'wix-web-module';
2import { siteProperties } from 'wix-business-tools.v2';
3import { elevate } from 'wix-auth';
4
5export const myGetSitePropertiesFunction = webMethod(Permissions.Anyone, async () => {
6 try {
7 const elevatedGetSiteProperties = elevate(siteProperties.getSiteProperties);
8 const mySiteProperties = await elevatedGetSiteProperties();
9
10 console.log('Success! Site properties:', mySiteProperties);
11 return mySiteProperties;
12 } catch (error) {
13 console.error(error);
14 // Handle the error
15 }
16});
17
18/* Promise resolves to:
19 * {
20 * "properties": {
21 * "address": {
22 * "apartmentNumber": "",
23 * "city": "Radlett",
24 * "coordinates": {
25 * "latitude": 51.6855755,
26 * "longitude": -0.3241171999999999
27 * }
28 * "country": "GB",
29 * "googleFormattedAddress": "10 Watford Road, Radlett, UK",
30 * "hint": {
31 * "placement": "BEFORE",
32 * "text": "Located on the ground floor"
33 * },
34 * "isPhysical": true,
35 * "state": "Greater London",
36 * "street": "Watford Road",
37 * "streetNumber": "10",
38 * "zip": "WD7 8LD",
39 * },
40 * "businessConfig": "UNKNOWN",
41 * "businessName": "Kids Clothes For You",
42 * "businessSchedule": {
43 * "periods": [
44 * {
45 * "closeDay": "MONDAY",
46 * "closeTime": "18:00",
47 * "openDay": "MONDAY",
48 * "openTime": "08:00"
49 * },
50 * {
51 * "closeDay": "TUESDAY",
52 * "closeTime": "18:00",
53 * "openDay": "TUESDAY",
54 * "openTime": "08:00"
55 * },
56 * {
57 * "closeDay": "WEDNESDAY",
58 * "closeTime": "18:00",
59 * "openDay": "WEDNESDAY",
60 * "openTime": "08:00"
61 * },
62 * {
63 * "closeDay": "THURSDAY",
64 * "closeTime": "18:00",
65 * "openDay": "THURSDAY",
66 * "openTime": "08:00"
67 * },
68 * {
69 * "closeDay": "FRIDAY",
70 * "closeTime": "18:00",
71 * "openDay": "FRIDAY",
72 * "openTime": "08:00"
73 * }
74 * ],
75 * "specialHourPeriod": [
76 * {
77 * "comment": "Half price in the lead up to Christmas!",
78 * "endDate": "2023-12-24T23:59:00Z",
79 * "isClosed": false,
80 * "startDate": "2023-12-01T00:00:00Z"
81 * }
82 * ]
83 * },
84 * "categories": {
85 * "businessTermId": "38194ba8-1218-431c-a007-09c26c75ee0d"
86 * "primary": "other",
87 * "secondary": [
88 * "Local Business"
89 * ],
90 * },
91 * "consentPolicy": {
92 * "advertising": true,
93 * "analytics": true,
94 * "dataToThirdParty": true,
95 * "essential": true,
96 * "functional": true
97 * },
98 * "description": "Clothes for little people, for a little price!",
99 * "email": "kidsclothes@example.com",
100 * "fax": "011-44-20-12345678",
101 * "language": "en",
102 * "locale": {
103 * "languageCode": "en",
104 * "country": "GB"
105 * },
106 * "logo": "a8a52b_bf5596e614d8484e9f1d429ac256e1ad~mv2.jpeg",
107 * "paymentCurrency": "GBP",
108 * "phone": "0208 123 4569",
109 * "siteDisplayName": "Business Tools",
110 * "timeZone": "Europe/London",
111 * "trackClicksAnalytics": false
112 * },
113 * "version": "60"
114 * }
115 */
116
Get Business Name and Description from Site Properties
This example uses elevate(), which enables site visitors to call functions without the required permissions. Exercise caution when using elevate() to prevent security vulnerabilities.

Copy Code
1import { Permissions, webMethod } from 'wix-web-module';
2import { siteProperties } from 'wix-business-tools.v2';
3import { elevate } from 'wix-auth';
4
5/* Sample options value:
6 * {
7 * fields: [
8 * 'businessName',
9 * 'description'
10 * ]
11 * }
12 */
13
14export const myGetSitePropertiesFunction = webMethod(Permissions.Anyone, async (options) => {
15 try {
16 const elevatedGetSiteProperties = elevate(siteProperties.getSiteProperties);
17 const mySiteProperties = await elevatedGetSiteProperties(options);
18
19 console.log('Success! Site properties:', mySiteProperties);
20 return mySiteProperties;
21 } catch (error) {
22 console.error(error);
23 // Handle the error
24 }
25});
26
27/* Promise resolves to:
28 * {
29 * "properties": {
30 * "businessName": "Kids Clothes For You",
31 * "description": "Clothes for little people, for a little price!",
32 * "trackClicksAnalytics": false
33 * },
34 * "version": "60"
35 * }
36 */
37
getSiteProperties() with choice of fields

This code is an example of a webpage where the user uses checkboxes to indicate which of the site's details they want to view.

Copy Code
1/*********************************************
2 * Backend code - get-site-properties.web.js *
3 ********************************************/
4import { Permissions, webMethod } from 'wix-web-module';
5import { siteProperties } from 'wix-business-tools.v2';
6import { elevate } from 'wix-auth';
7
8export const displaySiteProperties = webMethod(Permissions.Anyone, async (options) => {
9 try {
10 const elevatedGetSiteProperties = elevate(siteProperties.getSiteProperties);
11 const mySiteProperties = await elevatedGetSiteProperties(options);
12
13 console.log('Success! Site properties:', mySiteProperties);
14 return mySiteProperties;
15 } catch (error) {
16 console.error(error);
17 throw new Error(error);
18 }
19});
20
21
22/*************
23 * Page code *
24 ************/
25
26import { displaySiteProperties } from 'backend/get-site-properties.web';
27
28$w.onReady(() => {
29 $w('#submit').onClick(async () => {
30 const checkedFields = getFields();
31
32 if (!checkedFields.length) {
33 $w('#chooseAFieldsMsg').show();
34 setTimeout(() => {
35 $w('#chooseAFieldsMsg').hide();
36 }, 10000);
37 } else {
38 const fieldOptions = {
39 fields: checkedFields
40 }
41 const mySiteProperties = await displaySiteProperties(fieldOptions);
42
43 console.log('Chosen site properties are being displayed on the page:', mySiteProperties);
44 $w('#siteProperties').text = mySiteProperties;
45 }
46
47 });
48});
49
50function getFields() {
51 const checkedFields = [];
52 if ($w('#address').checked) {
53 checkedFields.push('address');
54 }
55 if ($w('#businessConfig').checked) {
56 checkedFields.push('businessConfig');
57 }
58 if ($w('#businessSchedule').checked) {
59 checkedFields.push('businessSchedule');
60 }
61 if ($w('#categories').checked) {
62 checkedFields.push('categories');
63 }
64 if ($w('#consentPolicy').checked) {
65 checkedFields.push('consentPolicy');
66 }
67 if ($w('#description').checked) {
68 checkedFields.push('description');
69 }
70 if ($w('#email').checked) {
71 checkedFields.push('email');
72 }
73 if ($w('#fax').checked) {
74 checkedFields.push('fax');
75 }
76 if ($w('#language').checked) {
77 checkedFields.push('language');
78 }
79 if ($w('#locale').checked) {
80 checkedFields.push('locale');
81 }
82 if ($w('#logo').checked) {
83 checkedFields.push('logo');
84 }
85 if ($w('#paymentCurrency').checked) {
86 checkedFields.push('paymentCurrency');
87 }
88 if ($w('#phone').checked) {
89 checkedFields.push('phone');
90 }
91 if ($w('#siteDisplayName').checked) {
92 checkedFields.push('siteDisplayName');
93 }
94 if ($w('#timeZone').checked) {
95 checkedFields.push('timeZone');
96 }
97 if ($w('#trackClicksAnalytics').checked) {
98 checkedFields.push('trackClicksAnalytics');
99 }
100
101 return checkedFields;
102}