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: replace items per list config value#}
  5.         {% set reviewsPerListPage = 10 %}
  6.         {#TODO: replace current list page value#}
  7.         {% set currentListPage = 1 %}
  8.         {% set productReviewCount = reviews|length %}
  9.         {% if productReviewCount > 0 %}
  10.             {% set productAvgRating = reviews.matrix.averageRating|round(2, 'floor')  %}
  11.         {% endif %}
  12.         {# TODO: 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 %}
  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.                                      itemprop="review-list">
  62.                                     {% block page_product_detail_review_list %}
  63.                                         {% block page_product_detail_review_list_actions %}
  64.                                             <div class="row align-items-center product-detail-review-actions">
  65.                                                 {% set formAjaxSubmitOptions = {
  66.                                                     replaceSelectors: [".js-review-container"],
  67.                                                     submitOnChange: true
  68.                                                 } %}
  69.                                                 {% block page_product_detail_review_list_action_language %}
  70.                                                     <div class="col product-detail-review-language">
  71.                                                         {% if foreignReviewsCount > 0 %}
  72.                                                             <form class="product-detail-review-language-form"
  73.                                                                   action="{{ path('frontend.product.reviews', { productId: reviews.productId, parentId: reviews.parentId }) }}"
  74.                                                                   method="post"
  75.                                                                   data-form-ajax-submit="true"
  76.                                                                   data-form-ajax-submit-options='{{ formAjaxSubmitOptions|json_encode }}'>
  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="custom-control custom-switch">
  87.                                                                     {#TODO: set checked and disabled state#}
  88.                                                                     <input type="checkbox"
  89.                                                                            class="custom-control-input"
  90.                                                                            id="showForeignReviews"
  91.                                                                            value="filter-language"
  92.                                                                            name="language"
  93.                                                                             {% if app.request.get('language') %}
  94.                                                                             checked="checked"
  95.                                                                             {% endif %}>
  96.                                                                     <label class="custom-control-label form-label"
  97.                                                                            for="showForeignReviews">
  98.                                                                         <small>{{ "detail.reviewLanguageFilterLabel"|trans|sw_sanitize }}</small>
  99.                                                                     </label>
  100.                                                                 </div>
  101.                                                             </form>
  102.                                                         {% endif %}
  103.                                                     </div>
  104.                                                 {% endblock %}
  105.                                                 {% block page_product_detail_review_list_action_sortby %}
  106.                                                     <div class="col-12 col-md-auto product-detail-review-sortby">
  107.                                                         {% set formAjaxSubmitOptions = {
  108.                                                             replaceSelectors: [
  109.                                                                 ".js-review-info",
  110.                                                                 ".js-review-teaser",
  111.                                                                 ".js-review-content"
  112.                                                             ],
  113.                                                             submitOnChange: true
  114.                                                         } %}
  115.                                                         {% block page_product_detail_review_list_action_sortby_form %}
  116.                                                             <form class="form-inline product-detail-review-sortby-form"
  117.                                                                   action="{{ path('frontend.product.reviews', { productId: reviews.productId, parentId: reviews.parentId }) }}"
  118.                                                                   method="post"
  119.                                                                   data-form-ajax-submit="true"
  120.                                                                   data-form-ajax-submit-options='{{ formAjaxSubmitOptions|json_encode }}'>
  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="custom-select custom-select-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.                                                 {% endblock %}
  157.                                             </div>
  158.                                             <hr/>
  159.                                             {# TODO: calculate reviews in current language in list #}
  160.                                             {% set listReviewsCount = productReviewCount - foreignReviewsCount %}
  161.                                             {# TODO: fix if reviews in foreign language are more than in customer language#}
  162.                                             {% if listReviewsCount < 0 %}
  163.                                                 {% set listReviewsCount = 0 %}
  164.                                             {% endif %}
  165.                                             <p class="text-right product-detail-review-counter">
  166.                                                 {% if (listReviewsCount > 1 and listReviewsCount > reviewsPerListPage) %}
  167.                                                     <small><strong>{{ currentListPage }}</strong> - <strong>{{ reviewsPerListPage }}</strong> {{ "detail.reviewCountBefore"|trans|sw_sanitize }} <strong>{{ listReviewsCount }}</strong> {{ "detail.reviewCountAfter"|trans({'%count%': listReviewsCount })|sw_sanitize }}</small>
  168.                                                 {% elseif listReviewsCount > 0 %} {# TODO fix detail.reviewCountAfter snippet for listReviewsCount = 0#}
  169.                                                     <small><strong>{{ listReviewsCount }}</strong> {{ "detail.reviewCountAfter"|trans({'%count%': listReviewsCount })|sw_sanitize }}</small>
  170.                                                 {% endif %}
  171.                                             </p>
  172.                                         {% endblock %}
  173.                                         {% block page_product_detail_review_list_content %}
  174.                                             {% for review in reviews %}
  175.                                                 <div class="product-detail-review-list-content">
  176.                                                     {% sw_include '@Storefront/storefront/page/product-detail/review/review-item.html.twig' %}
  177.                                                 </div>
  178.                                             {% endfor %}
  179.                                         {% endblock %}
  180.                                         {% block page_product_detail_review_list_paging %}
  181.                                             {% set criteria = reviews.criteria %}
  182.                                             {% set totalPages = (reviews.total/criteria.limit)|round(0,'ceil') %}
  183.                                             {% if totalPages > 1 %}
  184.                                                 {% set formAjaxSubmitOptions = {
  185.                                                     replaceSelectors: ".js-review-container",
  186.                                                     submitOnChange: true
  187.                                                 } %}
  188.                                                 {% block page_product_detail_review_list_paging_form %}
  189.                                                     <div class="product-detail-review-pagination">
  190.                                                         <form class="product-detail-review-pagination-form"
  191.                                                               action="{{ path('frontend.product.reviews', { productId: reviews.productId }) }}"
  192.                                                               method="post"
  193.                                                               data-form-ajax-submit="true"
  194.                                                               data-form-ajax-submit-options='{{ formAjaxSubmitOptions|json_encode }}'>
  195.                                                             {% block page_product_detail_review_list_paging_csrf %}
  196.                                                                 {{ sw_csrf('frontend.product.reviews') }}
  197.                                                             {% endblock %}
  198.                                                             {% if app.request.get('limit') %}
  199.                                                                 <input type="hidden" name="limit" value="{{ app.request.get('limit') }}">
  200.                                                             {% endif %}
  201.                                                             {% if app.request.get('language') %}
  202.                                                                 <input type="hidden" name="language" value="{{ app.request.get('language') }}">
  203.                                                             {% endif %}
  204.                                                             {% if app.request.get('sort') %}
  205.                                                                 <input type="hidden" name="sort" value="{{ app.request.get('sort') }}">
  206.                                                             {% endif %}
  207.                                                             {% if app.request.get('points') %}
  208.                                                                 {% for points in app.request.get('points') %}
  209.                                                                     <input type="hidden" name="points[]" value="{{ points }}">
  210.                                                                 {% endfor %}
  211.                                                             {% endif %}
  212.                                                             {% sw_include '@Storefront/storefront/component/pagination.html.twig' with {
  213.                                                                 entities: reviews,
  214.                                                                 criteria: reviews.criteria
  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 %}