Product Review
get each products review and write review for a product

Write a review

post
β€Ž
https://<domain>/<api prefix>/<version>/commerce/product/product-review/

Sample Code

Node
1
var request = require('request');
2
var options = {
3
'method': 'POST',
4
'url': 'https://<domain>/<api prefix>/<version>/commerce/product/product-review/',
5
'headers': {
6
'apikey': '<api key>',
7
'Authorization': 'Bearer <access token>',
8
},
9
formData: {
10
'comment': '<comment>',
11
'stars': '<star count>',
12
'bundle': '<bundle id>'
13
}
14
};
15
request(options, function (error, response) {
16
if (error) throw new Error(error);
17
console.log(response.body);
18
});
Copied!
PHP
1
<?php
2
​
3
$curl = curl_init();
4
​
5
curl_setopt_array($curl, array(
6
CURLOPT_URL => 'https://<domain>/<api prefix>/<version>/commerce/product/product-review/',
7
CURLOPT_RETURNTRANSFER => true,
8
CURLOPT_ENCODING => '',
9
CURLOPT_MAXREDIRS => 10,
10
CURLOPT_TIMEOUT => 0,
11
CURLOPT_FOLLOWLOCATION => true,
12
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
13
CURLOPT_CUSTOMREQUEST => 'POST',
14
CURLOPT_POSTFIELDS => array('bundle' => '<bundle_id>','comment' => '<>comment','stars' => '<stars_count>'),
15
CURLOPT_HTTPHEADER => array(
16
'apikey: <apikey>',
17
'Authorization: Bearer <access token>',
18
),
19
));
20
​
21
$response = curl_exec($curl);
22
​
23
curl_close($curl);
24
echo $response;
Copied!

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 Review Status

get
β€Ž
https://<domain>/<api prefix>/<version>/commerce/product/product-review/

Note:

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

Sample Code

Node

1
var request = require('request');
2
var options = {
3
'method': 'GET',
4
'url': 'https://<domain>/<api prefix>/<version>/commerce/product/product-review/',
5
'headers': {
6
'apikey': '<api key>',
7
'Authorization': 'Bearer <access token>',
8
'Cookie': 'defult_store_slug=admin_store; store_user=admin_store'
9
},
10
formData: {
11
​
12
}
13
};
14
request(options, function (error, response) {
15
if (error) throw new Error(error);
16
console.log(response.body);
17
});
Copied!

PHP

1
<?php
2
require_once 'HTTP/Request2.php';
3
$request = new HTTP_Request2();
4
$request->setUrl('https://<domain>/<api prefix>/<version>/commerce/product/product-review/');
5
$request->setMethod(HTTP_Request2::METHOD_GET);
6
$request->setConfig(array(
7
'follow_redirects' => TRUE
8
));
9
$request->setHeader(array(
10
'apikey' => '<api key>',
11
'Authorization' => 'Bearer <access token>',
12
'Cookie' => 'defult_store_slug=admin_store; store_user=admin_store'
13
));
14
try {
15
$response = $request->send();
16
if ($response->getStatus() == 200) {
17
echo $response->getBody();
18
}
19
else {
20
echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
21
$response->getReasonPhrase();
22
}
23
}
24
catch(HTTP_Request2_Exception $e) {
25
echo 'Error: ' . $e->getMessage();
26
}
Copied!

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.
Last modified 2mo ago