app/template/default/Product/list.twig line 1

Open in your IDE?
  1. {#
  2. This file is part of EC-CUBE
  3. Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
  4. http://www.ec-cube.co.jp/
  5. For the full copyright and license information, please view the LICENSE
  6. file that was distributed with this source code.
  7. #}
  8. {% extends 'default_frame.twig' %}
  9. {% set body_class = 'product_page' %}
  10. {% block javascript %}
  11.     <script>
  12.         eccube.productsClassCategories = {
  13.             {% for Product in pagination %}
  14.             "{{ Product.id|escape('js') }}": {{ class_categories_as_json(Product)|raw }}{% if loop.last == false %}, {% endif %}
  15.             {% endfor %}
  16.         };
  17.         $(function() {
  18.             // 表示件数を変更
  19.             $('.disp-number').change(function() {
  20.                 var dispNumber = $(this).val();
  21.                 $('#disp_number').val(dispNumber);
  22.                 $('#pageno').val(1);
  23.                 $("#form1").submit();
  24.             });
  25.             // 並び順を変更
  26.             $('.order-by').change(function() {
  27.                 var orderBy = $(this).val();
  28.                 $('#orderby').val(orderBy);
  29.                 $('#pageno').val(1);
  30.                 $("#form1").submit();
  31.             });
  32.             $('.add-cart').on('click', function(e) {
  33.                 var $form = $(this).parents('li').find('form');
  34.                 // 個数フォームのチェック
  35.                 var $quantity = $form.parent().find('.quantity');
  36.                 if ($quantity.val() < 1) {
  37.                     $quantity[0].setCustomValidity('{{ '1以上で入力してください。'|trans }}');
  38.                     setTimeout(function() {
  39.                         loadingOverlay('hide');
  40.                     }, 100);
  41.                     return true;
  42.                 } else {
  43.                     $quantity[0].setCustomValidity('');
  44.                 }
  45.                 e.preventDefault();
  46.                 $.ajax({
  47.                     url: $form.attr('action'),
  48.                     type: $form.attr('method'),
  49.                     data: $form.serialize(),
  50.                     dataType: 'json',
  51.                     beforeSend: function(xhr, settings) {
  52.                         // Buttonを無効にする
  53.                         $('.add-cart').prop('disabled', true);
  54.                     }
  55.                 }).done(function(data) {
  56.                     // レスポンス内のメッセージをalertで表示
  57.                     $.each(data.messages, function() {
  58.                         $('#ec-modal-header').text(this);
  59.                     });
  60.                     $('.ec-modal').show()
  61.                     // カートブロックを更新する
  62.                     $.ajax({
  63.                         url: '{{ url('block_cart') }}',
  64.                         type: 'GET',
  65.                         dataType: 'html'
  66.                     }).done(function(html) {
  67.                         $('.ec-headerRole__cart').html(html);
  68.                     });
  69.                 }).fail(function(data) {
  70.                     alert('{{ 'カートへの追加に失敗しました。'|trans }}');
  71.                 }).always(function(data) {
  72.                     // Buttonを有効にする
  73.                     $('.add-cart').prop('disabled', false);
  74.                 });
  75.             });
  76.         });
  77.         $('.ec-modal-wrap').on('click', function(e) {
  78.             // モーダル内の処理は外側にバブリングさせない
  79.             e.stopPropagation();
  80.         });
  81.         $('.ec-modal-overlay, .ec-modal, .ec-modal-close, .ec-inlineBtn--cancel').on('click', function() {
  82.             $('.ec-modal').hide()
  83.         });
  84.     </script>
  85. {% endblock %}
  86. {% block main %}
  87.     {% if search_form.category_id.vars.errors|length > 0 %}
  88.         <div class="ec-searchnavRole">
  89.             <p class="errormsg text-danger">{{ 'ご指定のカテゴリは存在しません'|trans }}</p>
  90.         </div>
  91.     {% else %}
  92.         <div class="ec-categoryListRole">
  93.             {% set Category = repository('Eccube\\Entity\\Category').find(1) %}
  94.             {% set cate_childs = Category.getDescendants %}
  95.             <div class="ec-categoryListRole__inner standard-inner1">
  96.                 <h2 class="ec-categoryListRole__title" data-aos="fade-up">CATEGORY</h2>
  97.                 <div class="ec-categoryList">
  98.                     <ul class="ec-categoryList__list">
  99.                         {% for cate in cate_childs %}
  100.                             <li class="ec-categoryList__item" data-aos="fade-up">
  101.                                 <a href="{{ url('product_list') }}?category_id={{ cate.id }}" class="ec-categoryList__link">
  102.                                     <span class="ec-categoryList__name">{{ cate.name }}</span>
  103.                                 </a>
  104.                             </li>
  105.                         {% endfor %}
  106.                     </ul>
  107.                 </div>
  108.             </div>
  109.         </div>
  110.         <div class="ec-categoryListRole">
  111.             {% set Category = repository('Eccube\\Entity\\Category').find(5) %}
  112.             {% set cate_childs = Category.getDescendants %}
  113.             <div class="ec-categoryListRole__inner standard-inner1">
  114.                 <h2 class="ec-categoryListRole__title" data-aos="fade-up">DESIGNER</h2>
  115.                 <div class="ec-categoryList">
  116.                     <ul class="ec-categoryList__list">
  117.                         {% for cate in cate_childs %}
  118.                             <li class="ec-categoryList__item" data-aos="fade-up">
  119.                                 <a href="{{ url('product_list') }}?category_id={{ cate.id }}" class="ec-categoryList__link">
  120.                                     <span class="ec-categoryList__name">{{ cate.name }}</span>
  121.                                 </a>
  122.                             </li>
  123.                         {% endfor %}
  124.                     </ul>
  125.                 </div>
  126.             </div>
  127.         </div>
  128.         
  129.         {% if pagination.totalItemCount > 0 %}
  130.             <div class="ec-shelfRole">
  131.                 <div class="ec-shelfRole__inner standard-inner1">
  132.                     <ul class="ec-shelfGrid">
  133.                         {% for Product in pagination %}
  134.                             <li class="ec-shelfGrid__item" data-aos="fade-up">
  135.                                 <a href="{{ url('product_detail', {'id': Product.id}) }}">
  136.                                     <p class="ec-shelfGrid__item-image">
  137.                                         <img src="{{ asset(Product.main_list_image|no_image_product, 'save_image') }}" alt="{{ Product.name }}" {% if loop.index > 5 %} loading="lazy"{% endif %}>
  138.                                     </p>
  139.                                     <p>{{ Product.name }}</p>
  140.                                     {% if Product.description_list %}
  141.                                         <p>{{ Product.description_list|raw|nl2br }}</p>
  142.                                     {% endif %}
  143.                                     <p class="price02-default">
  144.                                         {% if Product.hasProductClass %}
  145.                                             {% if Product.getPrice02Min == Product.getPrice02Max %}
  146.                                                 {{ Product.getPrice02IncTaxMin|price }}<span>(税込)</span>
  147.                                             {% else %}
  148.                                                 {{ Product.getPrice02IncTaxMin|price }} ~ {{ Product.getPrice02IncTaxMax|price }}<span>(税込)</span>
  149.                                             {% endif %}
  150.                                         {% else %}
  151.                                             {{ Product.getPrice02IncTaxMin|price }}
  152.                                             <span>(税込)</span>
  153.                                         {% endif %}
  154.                                     </p>
  155.                                 </a>
  156.                             </li>
  157.                         {% endfor %}
  158.                     </ul>
  159.                 </div>
  160.             </div>
  161.             <div class="ec-pagerRole" data-aos="fade-up">
  162.                 {% include "pager.twig" with {'pages': pagination.paginationData} %}
  163.             </div>
  164.         {% else %}
  165.             <div class="ec-searchnavRole" data-aos="fade-up">
  166.                 <div class="ec-shelfRole__inner standard-inner1">
  167.                     <ul class="ec-shelfGrid"></ul>
  168.                     <p class="errormsg text-danger">{{ '該当する商品がありませんでした。'|trans }}</p>
  169.                     <ul class="ec-shelfGrid"></ul>
  170.                 </div>
  171.             </div>
  172.         {% endif %}
  173.     {% endif %}
  174. {% endblock %}