Reviews Actions
fetchProductReviews
Section titled “fetchProductReviews”Requests product reviews from the server.
import { fetchProductReviews } from '@shopgate/engage/reviews';
const productId = '25',const limit = 5,const sort = 'priceAsc',
dispatch(fetchProductReviews(productId, limit, sort));Parameters
Section titled “Parameters”productId(string): The product ID.limit(number): The maximum number of reviews to fetch. Default is set to 2.sort(string): The sort scheme. Default is by relevance.- Possible Values:
relevance,dateAsc,dateDesc,rateAsc, andrateDesc. All of these values are constants. They can be imported like this:
- Possible Values:
import { SORT_RELEVANCE, SORT_DATE_ASC, SORT_DATA_DESC, SORT_RATE_ASC, SORT_RATE_DEC } from '@shopgate/engage/core';fetchReviews
Section titled “fetchReviews”Requests product reviews by the given ID from the server.
import { fetchReviews } from '@shopgate/engage/reviews'
const productId = '25',const limit = 5,const offset = 2,const sort = 'priceAsc',
dispatch(fetchReviews(productId, limit, offset, sort));Parameters
Section titled “Parameters”productId(string): The product ID.limit(number): The maximum number of reviews to fetch. Default is set to 2.offset(number): The review list offset. Default is 0.sort(string): The sort scheme. Default is by relevance.- Possible Values:
relevance,dateAsc,dateDesc,rateAsc, andrateDesc. All of these values are constants. They can be imported like this:
- Possible Values:
import { SORT_RELEVANCE, SORT_DATE_ASC, SORT_DATA_DESC, SORT_RATE_ASC, SORT_RATE_DEC } from '@shopgate/engage/core';fetchUserReview
Section titled “fetchUserReview”Requests a user review for a product from the server.
import { fetchUserReview } from '@shopgate/engage/reviews'
const productId = '25';
dispatch(fetchUserReview(productId))Parameters
Section titled “Parameters”productId(string): The product ID.
flushUserReview
Section titled “flushUserReview”Removes the relation between the user and their reviews when a user is logged out.
import { flushUserReview } from '@shopgate/engage/reviews'
dispatch(flushUserReview());submitReview
Section titled “submitReview”Submits a user review for a product to the server.
import { submitReview } from '@shopgate/engage/reviews'
const review = { 'author': 'Bill Demapps', 'productId': '25', 'rate': 75, 'review': 'Loved it!', 'title': 'Works Great',};
const update = true;
dispatch(submitReview(review, update));Parameters
Section titled “Parameters”review(Object): The review data.- The required fields are
rate,title,review,author, andproductId. update(boolean): Indicates whether the update pipeline or the add pipeline is called.

