The Vue Storefront Essentials Course is now available! Learn More
Product reviews

Product reviews

Introduction

This section will cover the basics of product reviews.

API Reference

You can find all available BigCommerce module methods and their description in the API Reference.

Creating a product review.

To add a review for a product, you can use the createProductReview method.

The payload neccessary for the review can be referenced from the CreateProductReviewProps interface

import { sdk } from '~/sdk.config.ts';

const createProductReviewResponse = await sdk.bigcommerce.createProductReview({
  title: 'New review',
  productId: 132
});

Getting a single product review

To fetch data about a single review, you can use the getProductReview method, by passing the id of the product and the id of the review.

import { sdk } from '~/sdk.config.ts';

const getProductReviewResponse = await sdk.bigcommerce.getProductReview({
  productId: 132,
  reviewId: 91
});

Getting all reviews for a product

To fetch all of the review, you can use the getProductReviewCollection method, by passing the id of the product

import { sdk } from '~/sdk.config.ts';

const getProductReviewCollectionResponse = await sdk.bigcommerce.getProductReviewCollection({
  productId: 132,
});

You can specify the fields you want to exclude in the response by passing them as the excluded_fields in a comma-separated list. The specified fields will be excluded from a response. The ID cannot be excluded.

import { sdk } from '~/sdk.config.ts';

const getProductReviewCollectionResponse = await sdk.bigcommerce.getProductReviewCollection({
  productId: 132,
  exclude_fields: 'title'
});