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/

Using this API users can write a review for a previously purchased product.

Headers

Request Body

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': 'https://<domain>/<api prefix>/<version>/commerce/product/product-review/',
  'headers': {
    'apikey': '<api key>',
    'Authorization': 'Bearer <access token>',
  },
  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

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://<domain>/<api prefix>/<version>/commerce/product/product-review/',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS => array('bundle' => '<bundle_id>','comment' => '<>comment','stars' => '<stars_count>'),
  CURLOPT_HTTPHEADER => array(
    'apikey: <apikey>',
    'Authorization: Bearer <access token>',
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

Error Responses

Get Review Status

GET ‎https://<domain>/<api prefix>/<version>/commerce/product/product-review/

This endpoint will return how many times the user purchased this product previously.

Query Parameters

Headers

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': 'https://<domain>/<api prefix>/<version>/commerce/product/product-review/',
  '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('https://<domain>/<api prefix>/<version>/commerce/product/product-review/');
$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

Last updated