Product Review

get each products review and write review for a product

Write a review

post
write review

https://<domain>/commerce/product/product-review/
Using this API users can write a review for a previously purchased product.
Request
Response
Request
Headers
apikey
required
string
​
Authorization
required
string
Bearer Access Token
Body Parameters
comment
required
string
review comment
bundle
required
number
product bundle id (unique id)
stars
required
number
no. of stars given
Response
200: OK
HTTP/1.1 200 OK
Content-Type: application/json
​
Body:
{
"status_code": 200,
"errors": {},
"data": {}
}

Sample Code

Node

var request = require('request');
var options = {
'method': 'POST',
'url': '<domain>/commerce/product/product-review/',
'headers': {
'apikey': '<api key>',
'Authorization': 'Bearer <access token>',
'Cookie': 'defult_store_slug=admin_store; store_user=admin_store'
},
formData: {
'comment': '<comment>',
'stars': '<star count>',
'bundle': '<bundle id>'
}
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});

PHP

<?php
require_once 'HTTP/Request2.php';
$request = new HTTP_Request2();
$request->setUrl('<domain>/commerce/product/product-review/');
$request->setMethod(HTTP_Request2::METHOD_POST);
$request->setConfig(array(
'follow_redirects' => TRUE
));
$request->setHeader(array(
'apikey' => '<api key>',
'Authorization' => 'Bearer <access token>',
'Cookie' => 'defult_store_slug=admin_store; store_user=admin_store'
));
$request->addPostParameter(array(
'comment' => '<comment>',
'stars' => '<star count>',
'bundle' => '<bundle id>'
));
try {
$response = $request->send();
if ($response->getStatus() == 200) {
echo $response->getBody();
}
else {
echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
$response->getReasonPhrase();
}
}
catch(HTTP_Request2_Exception $e) {
echo 'Error: ' . $e->getMessage();
}

Error Responses

Status code

Error Type

Field

Description

400

Validation Error

bundle

Bundle id is required.

This field may not be blank.

Product with bundle id not exist.

400

Validation Error

comment

comment is required

400

Validation Error

stars

stars count is required

get
​

https://<domain>/commerce/product/product-review/
This endpoint will return how many times the user purchased this product previously.
Request
Response
Request
Headers
apikey
required
string
apikey
Authorization
required
string
Bearer Access Token
Query Parameters
bundle_id
required
string
​
Response
200: OK
HTTP/1.1 200 OK
Content-Type: application/json
​
Body:
{
"status_code": 200,
"errors": {},
"data": 0
}

Note:

All Reviews from different users of a product are fetched in product details api.

Sample Code

Node

var request = require('request');
var options = {
'method': 'GET',
'url': '<domain>/commerce/product/product-review/?bundle_id=<bundle_id>',
'headers': {
'apikey': '<api key>',
'Authorization': 'Bearer <access token>',
'Cookie': 'defult_store_slug=admin_store; store_user=admin_store'
},
formData: {
​
}
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});

PHP

<?php
require_once 'HTTP/Request2.php';
$request = new HTTP_Request2();
$request->setUrl('<domain>/commerce/product/product-review/?bundle_id=<bundle_id>');
$request->setMethod(HTTP_Request2::METHOD_GET);
$request->setConfig(array(
'follow_redirects' => TRUE
));
$request->setHeader(array(
'apikey' => '<api key>',
'Authorization' => 'Bearer <access token>',
'Cookie' => 'defult_store_slug=admin_store; store_user=admin_store'
));
try {
$response = $request->send();
if ($response->getStatus() == 200) {
echo $response->getBody();
}
else {
echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
$response->getReasonPhrase();
}
}
catch(HTTP_Request2_Exception $e) {
echo 'Error: ' . $e->getMessage();
}

Error Responses

Status Code

Error Type

Field

Description

400

Validation Error

bundle_id

Bundle id is required.

This field may not be blank.

Product with bundle id not exist.