Definition
https://staticw2.yotpo.com/batch
Body
Parameter | Type | Description |
---|---|---|
| string | The store ID |
| string | An array of widget types (methods) and an hash of the parameters for each method |
| object | The specific parameters for the method |
| boolean false | Defines if the response should be for a mobile device or a desktop |
Note:
In order for the Reviews Widget to appear on product pages, be sure to add the HTML below to your product page template. Replace each data element with the appropriate values of your website and product attributes. Note that the data-product-id attribute only supports alphanumeric (a...z, A...Z, 0...9) and "_" and "-" symbols. 👇
<div class="yotpo yotpo-main-widget"
data-product-id="SKU/Product_ID"
data-price="Product Price"
data-currency="Price Currency"
data-name="Product Title"
data-url="The url to the page where the product is (url escaped)"
data-image-url="The product image url. Url escaped">
</div>
Batch payload types
Methods | Parameters | Batch Result |
---|---|---|
|
| Full HTML of a reviews widget which belongs to a specific product |
|
| Star rating widget that belongs to the same specific product |
|
| Reviews tab that opens the site and product reviews pop-up |
|
| Embedded widget |
| None ("params" : {}) | The Yotpo badge |
|
| A summary of the number of questions and answers per product |
Example
{
"methods": [
{
"method":"main_widget",
"params": {
"pid": "334342199",
"page":"2"
}
},
{
"method":"bottomline",
"params": {
"pid": "334342199"
},
"format": "json"
}
],
"app_key":"YOUR_APP_KEY",
"is_mobile":"false"
}
Result format
[
{
"method":"main_widget",
"result":"<div class="yotpo-display-wrapper yotpo-no-reviews" style="visibility: hidden;"> <div class="yotpo-label yotpo-small-box "> ....... // HTML is cut for brevity"},
{ "method":"bottomline",
"result":"<span class="yotpo-display-wrapper" style="visibility: hidden;"> <div class="standalone-bottomline"> .... // HTML is cut for brevity"
}
]
The methods parameter is an array of methods. Each method is a hash containing the method and parameters, which is an hash of the parameters for the method.
Note:
- Include the empty params attribute - "params" : {} - for the badge method
- The pid parameter is mandatory and cannot contain the "/" symbol
Tip:
It is highly recommended to develop a cache mechanism to save the payload locally and to refresh it periodically. The purpose of this caching is to avoid long loading times every time the widget loads.