vendor/shopware/storefront/Resources/views/storefront/page/product-detail/review/review.html.twig line 1

Open in your IDE?
  1. {% sw_extends '@Storefront/storefront/utilities/offcanvas.html.twig' %}
  2. {% block utilities_offcanvas_content %}
  3.     {% block page_product_detail_review_container %}
  4.         {# TODO NEXT-16993 - replace items per list config value #}
  5.         {% set reviewsPerListPage = 10 %}
  6.         {# TODO NEXT-16994 - replace current list page value #}
  7.         {% set currentListPage = 1 %}
  8.         {% set productReviewCount = reviews.totalReviews %}
  9.         {% if productReviewCount > 0 %}
  10.             {% set productAvgRating = reviews.matrix.averageRating|round(2, 'common')  %}
  11.         {% endif %}
  12.         {# TODO NEXT-16994 - replace language flag #}
  13.         {% set foreignReviewsCount = 150 %}
  14.         <div class="product-detail-review tab-pane-container">
  15.             {% block page_product_detail_review_tab_pane %}
  16.                 <div class="row product-detail-review-content js-review-container">
  17.                     {% block page_product_detail_review_aside %}
  18.                         <div class="col-sm-4">
  19.                             {% block page_product_detail_review_widget_container %}
  20.                                 {% sw_include '@Storefront/storefront/page/product-detail/review/review-widget.html.twig' %}
  21.                             {% endblock %}
  22.                         </div>
  23.                     {% endblock %}
  24.                     {% block page_product_detail_review_main %}
  25.                         <div class="col product-detail-review-main js-review-content">
  26.                             {% block page_product_detail_review_alert %}
  27.                                 {% if ratingSuccess == 1 %}
  28.                                     {% sw_include '@Storefront/storefront/utilities/alert.html.twig' with {
  29.                                         type: "success",
  30.                                         content: "detail.reviewFormSuccessAlert"|trans|sw_sanitize
  31.                                     } %}
  32.                                 {% elseif ratingSuccess == 2  %}
  33.                                     {% sw_include '@Storefront/storefront/utilities/alert.html.twig' with {
  34.                                         type: "success",
  35.                                         content: "detail.reviewFormSuccessUpdateAlert"|trans|sw_sanitize
  36.                                     } %}
  37.                                 {% elseif ratingSuccess == -1  %}
  38.                                     {% sw_include '@Storefront/storefront/utilities/alert.html.twig' with {
  39.                                         type: "danger",
  40.                                         content: "detail.reviewFormErrorAlert"|trans|sw_sanitize
  41.                                     } %}
  42.                                 {% endif %}
  43.                             {% endblock %}
  44.                             {% block page_product_detail_review_form_container %}
  45.                                 <div class="collapse multi-collapse{% if ratingSuccess == -1 %} show{% endif %}"
  46.                                      id="review-form">
  47.                                     {% if context.customer and not context.customer.guest %}
  48.                                         <div class="product-detail-review-form">
  49.                                             {% sw_include '@Storefront/storefront/page/product-detail/review/review-form.html.twig' %}
  50.                                         </div>
  51.                                     {% else %}
  52.                                         <div class="product-detail-review-login">
  53.                                             {% sw_include '@Storefront/storefront/page/product-detail/review/review-login.html.twig' %}
  54.                                         </div>
  55.                                     {% endif %}
  56.                                 </div>
  57.                             {% endblock %}
  58.                             {% block page_product_detail_review_list_container %}
  59.                                 <div id="review-list"
  60.                                      class="collapse multi-collapse product-detail-review-list{% if ratingSuccess != -1 %} show{% endif %}">
  61.                                     {% block page_product_detail_review_list %}
  62.                                         {% block page_product_detail_review_list_actions %}
  63.                                             <div class="row align-items-center product-detail-review-actions">
  64.                                                 {% set formAjaxSubmitOptions = {
  65.                                                     replaceSelectors: [".js-review-container"],
  66.                                                     submitOnChange: true
  67.                                                 } %}
  68.                                                 {% block page_product_detail_review_list_action_language %}
  69.                                                     <div class="col product-detail-review-language">
  70.                                                         {% if foreignReviewsCount > 0 %}
  71.                                                             <form class="product-detail-review-language-form"
  72.                                                                   action="{{ path('frontend.product.reviews', { productId: reviews.productId, parentId: reviews.parentId }) }}"
  73.                                                                   method="post"
  74.                                                                   data-form-ajax-submit="true"
  75.                                                                   data-form-ajax-submit-options='{{ formAjaxSubmitOptions|json_encode }}'>
  76.                                                                 {% block page_product_detail_review_list_action_language_csrf %}
  77.                                                                     {{ sw_csrf('frontend.product.reviews') }}
  78.                                                                 {% endblock %}
  79.                                                                 {% if app.request.get('limit') %}
  80.                                                                     <input type="hidden" name="limit" value="{{ app.request.get('limit') }}">
  81.                                                                 {% endif %}
  82.                                                                 {% if app.request.get('sort') %}
  83.                                                                     <input type="hidden" name="sort" value="{{ app.request.get('sort') }}">
  84.                                                                 {% endif %}
  85.                                                                 <div class="{{ formSwitchWrapperClass }}">
  86.                                                                     {# TODO NEXT-16994 - set checked and disabled state #}
  87.                                                                     <input type="checkbox"
  88.                                                                            class="{{ formCheckInputClass }}"
  89.                                                                            id="showForeignReviews"
  90.                                                                            value="filter-language"
  91.                                                                            name="language"
  92.                                                                            {% if app.request.get('language') %}checked="checked"{% endif %}>
  93.                                                                     <label class="custom-control-label form-label"
  94.                                                                            for="showForeignReviews">
  95.                                                                         <small>{{ "detail.reviewLanguageFilterLabel"|trans|sw_sanitize }}</small>
  96.                                                                     </label>
  97.                                                                 </div>
  98.                                                             </form>
  99.                                                         {% endif %}
  100.                                                     </div>
  101.                                                 {% endblock %}
  102.                                                 {% block page_product_detail_review_list_action_sortby %}
  103.                                                     {% if productReviewCount > 0 %}
  104.                                                         <div class="col-12 col-md-auto product-detail-review-sortby">
  105.                                                             {% set formAjaxSubmitOptions = {
  106.                                                                 replaceSelectors: [
  107.                                                                     ".js-review-info",
  108.                                                                     ".js-review-teaser",
  109.                                                                     ".js-review-content"
  110.                                                                 ],
  111.                                                                 submitOnChange: true
  112.                                                             } %}
  113.                                                             {% block page_product_detail_review_list_action_sortby_form %}
  114.                                                                 <form class="form-inline product-detail-review-sortby-form"
  115.                                                                       action="{{ path('frontend.product.reviews', { productId: reviews.productId, parentId: reviews.parentId }) }}"
  116.                                                                       method="post"
  117.                                                                       data-form-ajax-submit="true"
  118.                                                                       data-form-ajax-submit-options='{{ formAjaxSubmitOptions|json_encode }}'>
  119.                                                                     {% block page_product_detail_review_list_action_sortby_form_csrf %}
  120.                                                                         {{ sw_csrf('frontend.product.reviews') }}
  121.                                                                     {% endblock %}
  122.                                                                     {% if app.request.get('limit') %}
  123.                                                                         <input type="hidden" name="limit" value="{{ app.request.get('limit') }}">
  124.                                                                     {% endif %}
  125.                                                                     {% if app.request.get('language') %}
  126.                                                                         <input type="hidden" name="language" value="{{ app.request.get('language') }}">
  127.                                                                     {% endif %}
  128.                                                                     {% if app.request.get('points') %}
  129.                                                                         {% for points in app.request.get('points') %}
  130.                                                                             <input type="hidden" name="points[]" value="{{ points }}">
  131.                                                                         {% endfor %}
  132.                                                                     {% endif %}
  133.                                                                     {% block page_product_detail_review_list_action_sortby_label %}
  134.                                                                         <label class="form-label product-detail-review-sortby-label"
  135.                                                                                for="reviewsSortby">
  136.                                                                             <small>{{ "detail.reviewSortLabel"|trans|sw_sanitize }}</small>
  137.                                                                         </label>
  138.                                                                     {% endblock %}
  139.                                                                     {% block page_product_detail_review_list_action_sortby_select %}
  140.                                                                         <select class="{{ formSelectClass }} {{ formSelectClass }}-sm"
  141.                                                                                 name="sort"
  142.                                                                                 id="reviewsSortby">
  143.                                                                             <option value="createdAt"{% if reviews.criteria.sorting.0.field == 'createdAt' %} selected{% endif %}>
  144.                                                                                 {{ "detail.reviewSortNewLabel"|trans|sw_sanitize }}
  145.                                                                             </option>
  146.                                                                             <option value="points"{% if reviews.criteria.sorting.0.field== 'points' %} selected{% endif %}>
  147.                                                                                 {{ "detail.reviewSortTopRatedLabel"|trans|sw_sanitize }}
  148.                                                                             </option>
  149.                                                                         </select>
  150.                                                                     {% endblock %}
  151.                                                                 </form>
  152.                                                             {% endblock %}
  153.                                                         </div>
  154.                                                     {% endif %}
  155.                                                 {% endblock %}
  156.                                             </div>
  157.                                             <hr/>
  158.                                             {# TODO NEXT-16994 - calculate reviews in current language in list #}
  159.                                             {% set listReviewsCount = productReviewCount - foreignReviewsCount %}
  160.                                             {# TODO NEXT-16994 - fix if reviews in foreign language are more than in customer language #}
  161.                                             {% if listReviewsCount < 0 %}
  162.                                                 {% set listReviewsCount = 0 %}
  163.                                             {% endif %}
  164.                                             <p class="text-right product-detail-review-counter">
  165.                                                 {% if (listReviewsCount > 1 and listReviewsCount > reviewsPerListPage) %}
  166.                                                     <small><strong>{{ currentListPage }}</strong> - <strong>{{ reviewsPerListPage }}</strong> {{ "detail.reviewCountBefore"|trans|sw_sanitize }} <strong>{{ listReviewsCount }}</strong> {{ "detail.reviewCountAfter"|trans({'%count%': listReviewsCount })|sw_sanitize }}</small>
  167.                                                 {% elseif listReviewsCount > 0 %} {# TODO (NEXT-16994) fix detail.reviewCountAfter snippet for listReviewsCount = 0#}
  168.                                                     <small><strong>{{ listReviewsCount }}</strong> {{ "detail.reviewCountAfter"|trans({'%count%': listReviewsCount })|sw_sanitize }}</small>
  169.                                                 {% endif %}
  170.                                             </p>
  171.                                         {% endblock %}
  172.                                         {% block page_product_detail_review_list_content %}
  173.                                             {% for review in reviews %}
  174.                                                 <div class="product-detail-review-list-content">
  175.                                                     {% sw_include '@Storefront/storefront/page/product-detail/review/review-item.html.twig' %}
  176.                                                 </div>
  177.                                             {% endfor %}
  178.                                         {% endblock %}
  179.                                         {% block page_product_detail_review_list_paging %}
  180.                                             {% set criteria = reviews.criteria %}
  181.                                             {% set totalPages = (productReviewCount/criteria.limit)|round(0,'ceil') %}
  182.                                             {% if totalPages > 1 %}
  183.                                                 {% set formAjaxSubmitOptions = {
  184.                                                     replaceSelectors: ".js-review-container",
  185.                                                     submitOnChange: true
  186.                                                 } %}
  187.                                                 {% block page_product_detail_review_list_paging_form %}
  188.                                                     <div class="product-detail-review-pagination">
  189.                                                         <form class="product-detail-review-pagination-form"
  190.                                                               action="{{ path('frontend.product.reviews', { productId: reviews.productId }) }}"
  191.                                                               method="post"
  192.                                                               data-form-ajax-submit="true"
  193.                                                               data-form-ajax-submit-options='{{ formAjaxSubmitOptions|json_encode }}'>
  194.                                                             {% block page_product_detail_review_list_paging_csrf %}
  195.                                                                 {{ sw_csrf('frontend.product.reviews') }}
  196.                                                             {% endblock %}
  197.                                                             {% if app.request.get('limit') %}
  198.                                                                 <input type="hidden" name="limit" value="{{ app.request.get('limit') }}">
  199.                                                             {% endif %}
  200.                                                             {% if app.request.get('language') %}
  201.                                                                 <input type="hidden" name="language" value="{{ app.request.get('language') }}">
  202.                                                             {% endif %}
  203.                                                             {% if app.request.get('sort') %}
  204.                                                                 <input type="hidden" name="sort" value="{{ app.request.get('sort') }}">
  205.                                                             {% endif %}
  206.                                                             {% if app.request.get('points') %}
  207.                                                                 {% for points in app.request.get('points') %}
  208.                                                                     <input type="hidden" name="points[]" value="{{ points }}">
  209.                                                                 {% endfor %}
  210.                                                             {% endif %}
  211.                                                             {% sw_include '@Storefront/storefront/component/pagination.html.twig' with {
  212.                                                                 entities: reviews,
  213.                                                                 criteria: criteria,
  214.                                                                 total: productReviewCount,
  215.                                                             }  %}
  216.                                                         </form>
  217.                                                     </div>
  218.                                                 {% endblock %}
  219.                                             {% endif %}
  220.                                         {% endblock %}
  221.                                     {% endblock %}
  222.                                     {% if productReviewCount <= 0 %}
  223.                                         {% block page_product_detail_review_list_empty %}
  224.                                             {% sw_include '@Storefront/storefront/utilities/alert.html.twig' with {
  225.                                                 type: "info",
  226.                                                 content: "detail.reviewListEmpty"|trans|sw_sanitize
  227.                                             } %}
  228.                                         {% endblock %}
  229.                                     {% endif %}
  230.                                 </div>
  231.                             {% endblock %}
  232.                         </div>
  233.                     {% endblock %}
  234.                 </div>
  235.             {% endblock %}
  236.         </div>
  237.     {% endblock %}
  238. {% endblock %}