Product Details (JS SDK)
Andrey Veprikov
Get Product List
Method Objective
The method allows getting a list of products in stock.
Syntax and parameters
personaclick("products", params, success, error);
Name | Type | Requirement | Description |
---|---|---|---|
params | object | optionally | Object with request parameters. |
success | function | optionally | A callback function, to which the API response will be passed. Response type: object. |
error | function | optionally | A callback function that will be called when an error occurs (any HTTP status code other than 200). |
Request parameters
Name | Type | Requirement | Description |
---|---|---|---|
limit | number | optionally | The maximum number of products in the API response (by default - 10). |
page | number | optionally | Page number (first page - 1, by default - 1). |
categories | string | optionally | Comma-separated category IDs. If used, the API response will return only those products that are in the specified categories. |
locations | string | optionally | Comma-separated location IDs. If used, the API will return only products available in the specified locations. Locations must be specified in the imported product catalog (XML, HTTP API). |
brands | string | optionally | Comma-separated vendor names. If used, the API response will return only the products of the listed vendors. The vendors must be listed in the product feed. |
filters | string | optionally | JSON string with the properties and their values that the products should match in the API response. The data matches the values of the "param" parameter of the product feed/catalog (XML, HTTP API). Format: {"property1":["value1","value2"],"property2":["value1","value2"]} See the example below. |
collapse | boolean | optionally | Allows disabling grouping of products by "group_id". This param's "false" value enables the API to return products regardless of a group. The "true" value is only one product of a group. The default value is "true". |
API response
Name | Type | Description |
---|---|---|
products | array | An array of objects with product information. Each object has the following properties:
|
products_total | number | The total number of products. The following request parameters don't affect this value: page, limit. |
brands | Object array | An array of objects with information about available brands. Each object has the following properties:
|
filters | Object | |
price_range | Object | The object containing the values of the minimum and maximum price of the products in the API response. Available properties:
|
Example of use
personaclick("products", { limit: 5, page: 3, categories: "146,100500", filters="{\"PARAM_NAME_1\":[\"PARAM_VALUE_1\",\"PARAM_VALUE_2\"],\"PARAM_NAME_2\":[\"PARAM_VALUE_1\",\"PARAM_VALUE_2\"]}" }, function(products) { // API response with products }, function(error) { // error details });
Get Product Counters
Method Objective
The method allows getting 24-hour and 15-minute counters of interaction with a product.
Syntax and parameters
personaclick("products", "counters", product_id, success, error);
Name | Type | Requirement | Description |
---|---|---|---|
product_id | number/string | required | Product ID. |
success | function | required | A callback function, to which the API response will be passed. Response type: object. |
error | function | optionally | A callback function that will be called when an error occurs (any HTTP status code other than 200). |
API response
Name | Type | Description |
---|---|---|
now | object | The product interaction counters for the last 15 minutes. The following properties are available:
|
daily | object | The product interaction counters for the last 24 hours. The following properties are available:
|
Example of use
personaclick("products", "counters", 100500, function(counters) { console.log(counters.now.view); // views in the last 15 minutes console.log(counters.daily.purchase); // purchases in the last 24 hours });
Get User's Current Cart
Method Objective
The method allows getting the current profile's cart.
Syntax and parameters
personaclick("cart", "get", success, error);
Name | Type | Requirement | Description |
---|---|---|---|
success | function | required | A callback function, to which the API response will be passed. Response type: object. |
error | function | optionally | A callback function that will be called when an error occurs (any HTTP status code other than 200). |
API response
Name | Type | Description |
---|---|---|
status | string | Contains "success" if the request is successful. |
data | object | Contains the "items" object array, where each object contains the following properties:
|
Example of use
personaclick("cart", "get", function(cart) { console.log(cart.data.items); });
Page Navigation
Related Pages
-
Page:
-
Page:
-
Page:
-
Page:
-
Page:
Related content
Copyright 2018-2024 PersonaClick