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

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.                                                                 {# @deprecated tag:v6.5.0 - Block page_product_detail_review_list_action_language_csrf will be removed. #}
  77.                                                                 {% block page_product_detail_review_list_action_language_csrf %}
  78.                                                                     {{ sw_csrf('frontend.product.reviews') }}
  79.                                                                 {% endblock %}
  80.                                                                 {% if app.request.get('limit') %}
  81.                                                                     <input type="hidden" name="limit" value="{{ app.request.get('limit') }}">
  82.                                                                 {% endif %}
  83.                                                                 {% if app.request.get('sort') %}
  84.                                                                     <input type="hidden" name="sort" value="{{ app.request.get('sort') }}">
  85.                                                                 {% endif %}
  86.                                                                 <div class="{{ formSwitchWrapperClass }}">
  87.                                                                     {# TODO NEXT-16994 - set checked and disabled state #}
  88.                                                                     <input type="checkbox"
  89.                                                                            class="{{ formCheckInputClass }}"
  90.                                                                            id="showForeignReviews"
  91.                                                                            value="filter-language"
  92.                                                                            name="language"
  93.                                                                            {% if app.request.get('language') %}checked="checked"{% endif %}>
  94.                                                                     <label class="custom-control-label form-label"
  95.                                                                            for="showForeignReviews">
  96.                                                                         <small>{{ "detail.reviewLanguageFilterLabel"|trans|sw_sanitize }}</small>
  97.                                                                     </label>
  98.                                                                 </div>
  99.                                                             </form>
  100.                                                         {% endif %}
  101.                                                     </div>
  102.                                                 {% endblock %}
  103.                                                 {% block page_product_detail_review_list_action_sortby %}
  104.                                                     {% if productReviewCount > 0 %}
  105.                                                         <div class="col-12 col-md-auto product-detail-review-sortby">
  106.                                                             {% set formAjaxSubmitOptions = {
  107.                                                                 replaceSelectors: [
  108.                                                                     ".js-review-info",
  109.                                                                     ".js-review-teaser",
  110.                                                                     ".js-review-content"
  111.                                                                 ],
  112.                                                                 submitOnChange: true
  113.                                                             } %}
  114.                                                             {% block page_product_detail_review_list_action_sortby_form %}
  115.                                                                 <form class="form-inline product-detail-review-sortby-form"
  116.                                                                       action="{{ path('frontend.product.reviews', { productId: reviews.productId, parentId: reviews.parentId }) }}"
  117.                                                                       method="post"
  118.                                                                       data-form-ajax-submit="true"
  119.                                                                       data-form-ajax-submit-options='{{ formAjaxSubmitOptions|json_encode }}'>
  120.                                                                     {# @deprecated tag:v6.5.0 - Block page_product_detail_review_list_action_sortby_form_csrf will be removed. #}
  121.                                                                     {% block page_product_detail_review_list_action_sortby_form_csrf %}
  122.                                                                         {{ sw_csrf('frontend.product.reviews') }}
  123.                                                                     {% endblock %}
  124.                                                                     {% if app.request.get('limit') %}
  125.                                                                         <input type="hidden" name="limit" value="{{ app.request.get('limit') }}">
  126.                                                                     {% endif %}
  127.                                                                     {% if app.request.get('language') %}
  128.                                                                         <input type="hidden" name="language" value="{{ app.request.get('language') }}">
  129.                                                                     {% endif %}
  130.                                                                     {% if app.request.get('points') %}
  131.                                                                         {% for points in app.request.get('points') %}
  132.                                                                             <input type="hidden" name="points[]" value="{{ points }}">
  133.                                                                         {% endfor %}
  134.                                                                     {% endif %}
  135.                                                                     {% block page_product_detail_review_list_action_sortby_label %}
  136.                                                                         <label class="form-label product-detail-review-sortby-label"
  137.                                                                                for="reviewsSortby">
  138.                                                                             <small>{{ "detail.reviewSortLabel"|trans|sw_sanitize }}</small>
  139.                                                                         </label>
  140.                                                                     {% endblock %}
  141.                                                                     {% block page_product_detail_review_list_action_sortby_select %}
  142.                                                                         <select class="{{ formSelectClass }} {{ formSelectClass }}-sm"
  143.                                                                                 name="sort"
  144.                                                                                 id="reviewsSortby">
  145.                                                                             <option value="createdAt"{% if reviews.criteria.sorting.0.field == 'createdAt' %} selected{% endif %}>
  146.                                                                                 {{ "detail.reviewSortNewLabel"|trans|sw_sanitize }}
  147.                                                                             </option>
  148.                                                                             <option value="points"{% if reviews.criteria.sorting.0.field== 'points' %} selected{% endif %}>
  149.                                                                                 {{ "detail.reviewSortTopRatedLabel"|trans|sw_sanitize }}
  150.                                                                             </option>
  151.                                                                         </select>
  152.                                                                     {% endblock %}
  153.                                                                 </form>
  154.                                                             {% endblock %}
  155.                                                         </div>
  156.                                                     {% endif %}
  157.                                                 {% endblock %}
  158.                                             </div>
  159.                                             <hr/>
  160.                                             {# TODO NEXT-16994 - calculate reviews in current language in list #}
  161.                                             {% set listReviewsCount = productReviewCount - foreignReviewsCount %}
  162.                                             {# TODO NEXT-16994 - fix if reviews in foreign language are more than in customer language #}
  163.                                             {% if listReviewsCount < 0 %}
  164.                                                 {% set listReviewsCount = 0 %}
  165.                                             {% endif %}
  166.                                             <p class="text-right product-detail-review-counter">
  167.                                                 {% if (listReviewsCount > 1 and listReviewsCount > reviewsPerListPage) %}
  168.                                                     <small><strong>{{ currentListPage }}</strong> - <strong>{{ reviewsPerListPage }}</strong> {{ "detail.reviewCountBefore"|trans|sw_sanitize }} <strong>{{ listReviewsCount }}</strong> {{ "detail.reviewCountAfter"|trans({'%count%': listReviewsCount })|sw_sanitize }}</small>
  169.                                                 {% elseif listReviewsCount > 0 %} {# TODO (NEXT-16994) fix detail.reviewCountAfter snippet for listReviewsCount = 0#}
  170.                                                     <small><strong>{{ listReviewsCount }}</strong> {{ "detail.reviewCountAfter"|trans({'%count%': listReviewsCount })|sw_sanitize }}</small>
  171.                                                 {% endif %}
  172.                                             </p>
  173.                                         {% endblock %}
  174.                                         {% block page_product_detail_review_list_content %}
  175.                                             {% for review in reviews %}
  176.                                                 <div class="product-detail-review-list-content">
  177.                                                     {% sw_include '@Storefront/storefront/page/product-detail/review/review-item.html.twig' %}
  178.                                                 </div>
  179.                                             {% endfor %}
  180.                                         {% endblock %}
  181.                                         {% block page_product_detail_review_list_paging %}
  182.                                             {% set criteria = reviews.criteria %}
  183.                                             {% set totalPages = (productReviewCount/criteria.limit)|round(0,'ceil') %}
  184.                                             {% if totalPages > 1 %}
  185.                                                 {% set formAjaxSubmitOptions = {
  186.                                                     replaceSelectors: ".js-review-container",
  187.                                                     submitOnChange: true
  188.                                                 } %}
  189.                                                 {% block page_product_detail_review_list_paging_form %}
  190.                                                     <div class="product-detail-review-pagination">
  191.                                                         <form class="product-detail-review-pagination-form"
  192.                                                               action="{{ path('frontend.product.reviews', { productId: reviews.productId, parentId: reviews.parentId }) }}"
  193.                                                               method="post"
  194.                                                               data-form-ajax-submit="true"
  195.                                                               data-form-ajax-submit-options='{{ formAjaxSubmitOptions|json_encode }}'>
  196.                                                             {# @deprecated tag:v6.5.0 - Block page_product_detail_review_list_paging_csrf will be removed. #}
  197.                                                             {% block page_product_detail_review_list_paging_csrf %}
  198.                                                                 {{ sw_csrf('frontend.product.reviews') }}
  199.                                                             {% endblock %}
  200.                                                             {% if app.request.get('limit') %}
  201.                                                                 <input type="hidden" name="limit" value="{{ app.request.get('limit') }}">
  202.                                                             {% endif %}
  203.                                                             {% if app.request.get('language') %}
  204.                                                                 <input type="hidden" name="language" value="{{ app.request.get('language') }}">
  205.                                                             {% endif %}
  206.                                                             {% if app.request.get('sort') %}
  207.                                                                 <input type="hidden" name="sort" value="{{ app.request.get('sort') }}">
  208.                                                             {% endif %}
  209.                                                             {% if app.request.get('points') %}
  210.                                                                 {% for points in app.request.get('points') %}
  211.                                                                     <input type="hidden" name="points[]" value="{{ points }}">
  212.                                                                 {% endfor %}
  213.                                                             {% endif %}
  214.                                                             {% sw_include '@Storefront/storefront/component/pagination.html.twig' with {
  215.                                                                 entities: reviews,
  216.                                                                 criteria: criteria,
  217.                                                                 total: productReviewCount,
  218.                                                             }  %}
  219.                                                         </form>
  220.                                                     </div>
  221.                                                 {% endblock %}
  222.                                             {% endif %}
  223.                                         {% endblock %}
  224.                                     {% endblock %}
  225.                                     {% if productReviewCount <= 0 %}
  226.                                         {% block page_product_detail_review_list_empty %}
  227.                                             {% sw_include '@Storefront/storefront/utilities/alert.html.twig' with {
  228.                                                 type: "info",
  229.                                                 content: "detail.reviewListEmpty"|trans|sw_sanitize
  230.                                             } %}
  231.                                         {% endblock %}
  232.                                     {% endif %}
  233.                                 </div>
  234.                             {% endblock %}
  235.                         </div>
  236.                     {% endblock %}
  237.                 </div>
  238.             {% endblock %}
  239.         </div>
  240.     {% endblock %}
  241. {% endblock %}