Product Review¶
product_review
module is used to display reviews that are already added to the product and a button which opens modal that allow user to add his review
Configuration parameters¶
displayTitle¶
int
if set to 1 the module title will be displayed.
title¶
string
Title of the module. If not specified no title will be displayed.
isEnabled¶
int
if set to 1 it will be possible to expand and collapse the module, otherwise it will always be expanded and it will not be possible to collapse it.
collapseExpand¶
string
Defines if module section should be opened by default. Values are 'expanded' or 'collapsed'.
showInfo¶
int
if set to 1 a description will be displayed.
description¶
string
a description of the module. If not specified no description will be displayed.
Module source code¶
{% from "@macros/module_accordion_toggler.twig" import module_accordion_toggler %}
{% from "@macros/icon.twig" import icon %}
{% set reviewsSettings = ObjectApi.getProductReviewsSettings() %}
{% if reviewsSettings.isReviewingEnabled %}
{% from "@macros/star_score.twig" import star_score %}
{% from "@macros/product_rating_and_review_modal_form.twig" import product_rating_and_review_modal_form %}
{% from "@macros/comment.twig" import comment %}
{% set product = ObjectApi.getProduct(product_id) %}
{% set modalName = 'product-rating-modal-' ~ moduleInstance %}
{% set isDisabled = not moduleConfig.isEnabled %}
{% set hasTitle = moduleConfig.displayTitle and moduleConfig.title %}
{% set isAccordionOpened = moduleConfig.collapseExpand == 'expanded' or isDisabled or not hasTitle %}
<h-accordion lazy class="accordion" {% if isDisabled %}disabled{% endif %}>
<h-accordion-group {% if isAccordionOpened %}opened{% endif %}>
{% if hasTitle %}
<h2 data-scroll="product-reviews" class="product-description__header module__header">
{{ module_accordion_toggler({ title: moduleConfig.title, isDisabled }) }}
</h2>
{% endif %}
<h-accordion-content>
<product-review product-id="{{ product.id }}" class="product-review">
<div class="grid__row grid__row_xs-hcenter grid__row_xs-vcenter">
<div class="grid__col">
{{
star_score(product.rate, {
numberOfStars: 5,
size: 'xl'
})
}}
</div>
<div class="grid__col">
<span class="font_semibold">{{ product.rate|number_format(2) }}</span>
</div>
</div>
<div class="grid__row grid__row_xs-hcenter grid__row_xs-vcenter mb-xs-4">
<div class="grid__col">
<span class="product-review__rate-count">{{ translate('Number of ratings') }}: {{ product.rateCount }}</span>
</div>
</div>
<div class="grid__row grid__row_xs-hcenter grid__row_xs-vcenter mb-xs-6">
<div class="grid__col">
<product-vote>
<h-modal-opener class="btn btn_secondary btn_s" name="{{ modalName }}">
{{ icon('icon-star', {
classNames: ['btn__icon', 'btn__icon_left']
}) }}
{{ translate('Rate and review') }}
</h-modal-opener>
</product-vote>
<product-vote class="info-box" disabled hidden>
<header class="info-box__header">
{{ translate('Feedback about this product has already been added.') }}
</header>
<p class="info-box__content">
{{ translate("If you've added a review and it doesn't appear on the list, it may be pending moderation.") }}
</p>
</product-vote>
{{ product_rating_and_review_modal_form(product, { instanceId: moduleInstance, modalName, imageSize: systemConfig.mSize }) }}
</div>
</div>
<div class="grid__row">
<div class="grid__col">
{% for comment in product.comments %}
{{ comment(comment) }}
{% endfor %}
</div>
</div>
{% if moduleConfig.showInfo == 1 and moduleConfig.description %}
<p class="product-review__description">{{ moduleConfig.description }}</p>
{% endif %}
</product-review>
</h-accordion-content>
</h-accordion-group>
</h-accordion>
{% endif %}
Webcomponents reference¶
Macros reference¶
Used Object Api methods¶
Used styles¶
Module configuration schema¶
[{
"elements":[
{
"type":"infobox",
"name":"infobox",
"options":{
"type":"blank",
"message":"#### Related settings in the admin panel%s- changing phrases in [translations](%s)%s- enabling the possibility of rating and reviewing products in [product feedback settings](%s)%s- [managing added reviews](%s)",
"placeholderValues":[
"\n",
"\/admin\/configLanguages\/list",
"\n",
"\/admin\/configComments",
"\n",
"\/admin\/comments\/list"
]
}
},{
"type":"checkbox",
"name":"displayTitle",
"label":"Display module title",
"defaultValue":1,
"children":[{
"type":"text",
"name":"title",
"label":"Module name",
"defaultValue":"Reviews",
"supportsTranslations":true,
"isRequired":1,
"relations":[
{
"parentName":"displayTitle",
"parentValueToActionsMap":[
{
"value" : 0,
"actions": ["setHidden", "setDisabled"]
},{
"value" : 1,
"actions": ["setVisible","setAvailable"]
}
]
}
]
}]
},{
"type":"checkbox",
"name":"isEnabled",
"label":"Allow to collapse and expand the module content",
"defaultValue":1,
"relations":[
{
"parentName":"displayTitle",
"parentValueToActionsMap":[
{
"value" : 0,
"actions": ["setDisabled"]
},{
"value" : 1,
"actions": ["setAvailable"]
}
]
}
],
"children":[{
"type":"radio",
"name":"collapseExpand",
"label":"Set as:",
"defaultValue":"expanded",
"relations":[
{
"parentName":"displayTitle",
"parentValueToActionsMap":[
{
"value" : 0,
"actions": ["setDisabled"]
},{
"value" : 1,
"actions": ["setAvailable"]
}
]
},
{
"parentName":"isEnabled",
"parentValueToActionsMap": [
{
"value" : 0,
"actions": ["setHidden","setDisabled"]
},{
"value" : 1,
"actions": ["setVisible","setAvailable"]
}
]
}
],
"options":{
"radioOptions":[
{"key": "expanded", "label": "expanded"},
{"key": "collapsed", "label": "collapsed (only module title visible)"}
]
}
}]
},{
"type":"checkbox",
"name":"showInfo",
"label":"Show info about how in-store reviews work (recommended)",
"defaultValue":0,
"children":[{
"type":"textarea",
"name":"description",
"supportsTranslations":true,
"label":"Description of how reviews work",
"defaultValue":"All reviews (positive and negative) are displayed. We don't verify that they come from customers who have purchased the product.",
"relations":[
{
"parentName":"showInfo",
"parentValueToActionsMap":[
{
"value" : 0,
"actions": ["setHidden","setDisabled"]
},{
"value" : 1,
"actions": ["setVisible","setAvailable"]
}
]
}
],
"isHidden": 1,
"hint": {
"message" : "#### Adapt the information to your settings%sLet your customers know how you collect and verify product reviews:%s- do you moderate reviews?%s- do you display all reviews (positive and negative)?%s- do reviews come only from logged-in customers?",
"placeholderValues" : [
"\n",
"\n",
"\n",
"\n"
]
}
}],
"hint":{
"message":"#### Recommendation of the EU Omnibus Directive%sYou have a responsibility to inform your customers about how in-store reviews work (under the Act: **Ustawa o przeciwdziaĆaniu nieuczciwym praktykom rynkowym**, Dz. U. z 2017 r. poz. 2070).",
"placeholderValues" : ["\n"]
}
}
],
"state":"unfolded",
"label":"General settings"
}]