Alokai
You are reading the documentation for v7.x and earlier, which is no longer the latest version. Switch to v8.x

createProductReview

Create new customer review as an anonymous user in SAP Commerce Cloud.

This method exchanges data with the createProductReview endpoint exposed by the SAP OCC API Products Controller.

Signature

export declare function createProductReview(
	context: SapccIntegrationContext,
	props: CreateProductReviewProps
): Promise<Review>;

Parameters

NameRequiredTypeDescription
contextRequiredSapccIntegrationContext
propsRequiredCreateProductReviewPropsProperties for creating a product review. Refer to its type definition to learn about possible properties.

Returns

Returns a representation of a Review.

Referenced Types

Examples

Creating a new product review.

import { sdk } from '~/sdk';

const review = {
  comment: 'This is a great product! Highly recommend it.',
  rating: 5,
  alias: 'Happy Customer'
};

const product = await sdk.commerce.createProductReview({ productCode: '12345', review });

Creating a new product review and selecting response fields.

import { sdk } from '~/sdk';

const review = {
  comment: 'This is a great product! Highly recommend it.',
  rating: 5,
  alias: 'Happy Customer'
};

const product = await sdk.commerce.createProductReview({ productCode: '12345', review, fields: 'BASIC' });

On this page