hasBeenReviewed(productId: string): boolean¶
The hasBeenReviewed
method returns an information about whether the product with a given ID has been reviewed before from the local storage.
Input parameters¶
productId¶
string
represents the ID of the product to check.
Returned value¶
A returned value has a type of boolean
. If a given product has been reviewed before the returned value will be true
. If none of these actions have been performed in the past it will be false
.
Example¶
In this example we make a RateAndReviewApi
call to check whether a given product has been reviewed before.
useStorefront((storefront) => {
const rateAndReviewApi = await storefront.getApi('rateAndReviewApi');
const hasBeenReviewed = rateAndReviewApi.hasBeenReviewed("145");
if (hasBeenReviewed) {
// do something if product has been reviewed
}
if (!hasBeenReviewed) {
// do something if product has not been reviewed
}
});