JavaScript SDK
This method is a wrapper around the REST API for fetching page content. It will automatically add the hello retail id of the user in the current session.
Description
Example
Response
The SDK consists of a single method that allows loading page content for a page with a specific key.
1
ADDWISH_PARTNER_NS.api.pages.load(key, options, callback(data));
Copied!
Argument
Description
key
Key The key of the page to load
options
A options object. Described below
callback
A callback function that will be called once the page content is loaded. The callback will receive a data object containing the response
Available Options:
Field
Type
Description
id
integer (optional)
Id of a version of a page. Only needed if you want to fetch the Draft version of a page.
url
string (optional)
URL of the page on your site that this page will be added to. Used for tracking and to find overrides for that specific url
layout
boolean
Landing pages may contain a layout that defines static content that can be shown around the dynamic content. This parameter specifies if that layout should be returned or not
format
string (optional)
Specify the format in which the API will return the results. "html" and "json" are accepted values, default value is "html".
fields
string[]
Product fields to consider, by default the system will consider all the fields of a product
params
object
Parameters that are passed as input to the product filters
trackingUserId
string
Hello retail id of the user visiting your site. This is used to apply personalization and for tracking purposes.
firstLoad
boolean
Indicates if this is the first render of the page. This allows the template to only return some content on the first load. Views of the page will only be tracked if firstLoad is true
products.start
integer
Starting point when fetching products for the page
products.count
integer
Number of products to return from the starting point
products.filters
string[]
List of filters to filter products by
products.sorting
string[]
List sorting options

HTML Format

1
ADDWISH_PARTNER_NS.api.pages.load(
2
"abcdefgh1234hy",
3
{
4
"id": 256,
5
"url": "/shoes",
6
"layout": true,
7
"firstLoad": true,
8
"format": "html", // it is optional, html is default value
9
"fields": ["id", "title", "price"], // fields of product to consider, by default it will consider all fields
10
"params": {"hierarchy": ["women", "shoes"]},
11
"products": {
12
"start": 0,
13
"count": 50,
14
"filters": [
15
"brand:The Brand",
16
"price:[10 TO 10]"
17
],
18
"sorting": [
19
"title DESC"
20
]
21
}
22
},
23
(data) => {
24
// inject the returned html into the page
25
// execute the returned javascript to setup interactive parts of the page
26
// inject the returned css
27
}
28
);
Copied!

JSON Format

1
ADDWISH_PARTNER_NS.api.pages.load(
2
"abcdefgh1234hy",
3
{
4
"id": 256,
5
"url": "/shoes",
6
"layout": true,
7
"firstLoad": true,
8
"format": "json", // it is optional, html is default value
9
"fields": ["id", "title", "price"], // fields of product to consider, by default it will consider all fields
10
"params": {"hierarchy": ["women", "shoes"]},
11
"products": {
12
"start": 0,
13
"count": 50,
14
"filters": [
15
"brand:The Brand",
16
"price:[10 TO 10]"
17
],
18
"sorting": [
19
"title DESC"
20
]
21
}
22
},
23
(data) => {
24
// inject the returned html into the page
25
// execute the returned javascript to setup interactive parts of the page
26
// inject the returned css
27
}
28
);
Copied!

HTML Format

1
{
2
layout: "<div>some html from the layout<div class=\"helloretail-pages-products\"></div> some more html</div>", // Layout from the beefree editor. Not included for category pages
3
firstLoad: true,
4
products: {
5
start: 0,
6
count: 50,
7
total: 500,
8
html: "<div>Products rendered using the design selected for the page</div>",
9
result: [], // this will be empty in case of html in format
10
javascript: "/* javascript from the design selected for the page */",
11
style: "/* css from the design selected for the page */"
12
}
13
}
Copied!

JSON Format

1
{
2
layout: "<div>some html from the layout<div class=\"helloretail-pages-products\"></div> some more html</div>", // Layout from the beefree editor. Not included for category pages
3
firstLoad: true,
4
products: {
5
start: 0,
6
count: 50,
7
total: 500,
8
html: "",
9
result: [
10
{
11
"title": "abc",
12
"url": "url/url.com",
13
"imgUrl": "imgurl/url.com",
14
"currency": "DKK",
15
"priceLowered": true,
16
"description": "sample description",
17
"keywords": "ab, gh, dd",
18
"inStock": true,
19
"productNumber": "product1234",
20
"variantProductNumbers": [],
21
"price": 233.44,
22
"previousPrice": 500.23,
23
"score": 7.0
24
},
25
...
26
],
27
javascript: "/* javascript from the design selected for the page */",
28
style: "/* css from the design selected for the page */"
29
}
30
}
Copied!
Copy link