shop:on_addProductReview
This AJAX handler allows you to build the Write a Review form. Please read this article to learn how you can implement the Write a Review form.
The Write a Review form should contain the following fields:
- rating - specifies a product rating. The rating should be a number (1-5) or empty value. If you do not need to implement the rating feature, you can skip this field. You can disable the ratings on the System/Settings/Ratings & Reviews Settings page.
- review_title - specifies a review title.
- review_author_name - specifies the review author name. You can hide this field for logged in customers, because if the customer is logged in, the review author name will match the customer's name.'
- review_author_email - specifies the review author email address. You can hide this field for logged in customers, because if the customer is logged in, the review author name will match the customer's email address.
- review_text - the review text.
Optional parameters
If you are implementing the Write a Review form on the Product Details page (a page which is based on the shop:product action), you don't need the form to contain the product_id field. Otherwise you need to create this hidden field, to identify a product you are adding a review for.
The redirect field allows you to specify a URL the browser should be redirected after the successful review post.
The handler creates the flash message (which you can output with the flash_message() function). If you want to suppress this message, create the no_flash hidden field with value 1 in your form. You can customize the default message with the message parameter. Example:
<input type="button" value="Submit" onclick="return $(this).getForm().sendRequest(
'shop:on_addProductReview', {
extraFields: {message: 'Your review has been succesfuly posted'},
update:{'product_page': 'product_partial'}
})"/>Generated PHP variables
After a successful review post, the handler creates the $review_posted PHP variable, which you can use for displaying custom messages.
Next: Shop_Product
Previous: resource_url
Return to Reference

