Review
Here is the list of properties and methods available on the review object. They work the same way in Twig and in PHP.
Property
id
ID of review.
productId
The reviewed product ID.
orderId
The related order ID of review.
variantIds
The variant IDs related to the review.
reviewerId
The customer user ID.
rating
Int. The rating value. null until the customer submits.
comment
String. The raw stored comment. See Printing the comment below before using it.
status
String. The status of review. (live, pending, expired)
dateCreated
DateTime. The review creation date, which is when the order moved to the desired status. This starts the review window.
dateUpdated
DateTime. The date that review was updated.
isPastReviewWindow
Bool. Whether the review window has closed.
Method
getProduct()
ProductElement. Get the reviewed Product. Returns null if the product was deleted.
getReviewer()
UserElement. Get the related user. Returns null if the customer was deleted.
getVariants()
List of VariantElement. Get the list of reviewed variants.
renderComment()
Markup. The comment, sanitized and safe to output directly.
Printing the comment
The comment is written by a customer, so it must never be printed with |raw.
Use renderComment(). It sanitizes the comment and returns markup Twig will not escape, so no |raw is needed.
It returns null when there is no comment, so a fallback is easy.
Last updated