$wsProductRating module, you can load, check, and display product ratings in the frontend.
Product ratings are an important element for purchasing decisions. They show customers the experiences of other buyers and increase trust in products.
Module overview
Example / excerpt of$wsProductRating
"ƒ()" denotes a function.
Methods overview
| Method | Return type | Description |
|---|---|---|
checkRatingExistence() | bool | Checks whether a rating exists for a product in connection with an order. |
loadAllProductRatings() | array | Loads all ratings of a product. |
loadRatingStatistics() | map | Loads statistics for the ratings of a product. |
loadSingleRating() | map | Loads a single rating based on product and order ID. |
loadLatestRating() | map | Loads the latest rating of the currently logged-in customer. |
loadRatingByAccount() | map | Loads a product rating of the currently logged-in customer. |
Templates
Product ratings are typically displayed on the product detail page (product.htm). They can also be included on category pages or in the order history to prompt customers to leave a rating.Variables
No variables are available for$wsProductRating.
Methods
$wsProductRating.checkRatingExistence()
Checks whether a rating already exists for a product in connection with an order. Signature$wsProductRating.checkRatingExistence(productId, orderId)
Return valuebool - true if a rating exists, otherwise false.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
productId | string | yes | ID of the product. |
orderId | string | yes | ID of the order. |
$wsProductRating.loadAllProductRatings()
Loads all ratings of a product. Signature$wsProductRating.loadAllProductRatings(productId)
Return valuearray - List with all ratings of the product.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
productId | string | yes | ID of the product. |
$wsProductRating.loadRatingStatistics()
Loads statistics for the ratings of a product. Signature$wsProductRating.loadRatingStatistics(productId)
Return valuemap - Map with rating statistics (e.g. average, count).
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
productId | string | yes | ID of the product. |
$wsProductRating.loadSingleRating()
Loads a single rating based on product and order ID. Signature$wsProductRating.loadSingleRating(productId, orderId)
Return valuemap - Map with the rating data.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
productId | string | yes | ID of the product. |
orderId | string | yes | ID of the order. |
$wsProductRating.loadLatestRatingForAccount()
Loads the latest rating of the currently logged-in customer. Signature$wsProductRating.loadLatestRatingForAccount()
Return valuemap - Map with the rating data.
Example that loads the customer’s latest rating.
$wsProductRating.loadRatingByAccount()
Loads a product rating of the currently logged-in customer. Signature$wsProductRating.loadRatingByAccount(productId)
Return valuemap - Map with the customer’s rating data.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
productId | string | yes | ID of the product. |
Actions
No actions are available for$wsProductRating.
