src/Eccube/Resource/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 tracking_script %}
  11. {% set item_list_name = "すべての商品" %}
  12. {% set item_list_id = "all" %}
  13. {% if search_form.category_id.vars.errors|length == 0 %}
  14.     {% if Category is not null %}
  15.         {% for Path in Category.path %}
  16.             {% set item_list_name = Path.name %}
  17.             {% set item_list_id = "category_"~Path.id %}
  18.         {% endfor %}
  19.     {% endif %}
  20.     {% if search_form.vars.value and search_form.vars.value.name %}
  21.         {% set item_list_name = "検索結果" %}
  22.         {% set item_list_id = "search" %}
  23.     {% endif %}
  24.     <script>
  25.     gtag('event', 'view_item_list', {
  26.     items: [{% for Product in pagination %}{
  27.     item_id: '{{ Product.id }}',
  28.     item_name: '{{ Product.name }}',
  29.     index: {{ loop.index }},
  30.     item_list_name: '{{ item_list_name }}',
  31.     item_list_id: '{{ item_list_id }}',
  32.     price: {{ Product.getPrice02IncTaxMin }},
  33.     currency: 'JPY'
  34.     },
  35.     {% endfor %}],
  36.     item_list_name: '{{ item_list_name }}',
  37.     item_list_id: '{{ item_list_id }}'
  38.     });
  39.     </script>
  40. {% endif %}
  41. {% endblock %}
  42. {% block javascript %}
  43.     <script>
  44.         eccube.productsClassCategories = {
  45.             {% for Product in pagination %}
  46.             "{{ Product.id|escape('js') }}": {{ class_categories_as_json(Product)|raw }}{% if loop.last == false %}, {% endif %}
  47.             {% endfor %}
  48.         };
  49.         $(function() {
  50.             // 表示件数を変更
  51.             $('.disp-number').change(function() {
  52.                 var dispNumber = $(this).val();
  53.                 $('#disp_number').val(dispNumber);
  54.                 $('#pageno').val(1);
  55.                 $("#form1").submit();
  56.             });
  57.             // 並び順を変更
  58.             $('.order-by').change(function() {
  59.                 var orderBy = $(this).val();
  60.                 $('#orderby').val(orderBy);
  61.                 $('#pageno').val(1);
  62.                 $("#form1").submit();
  63.             });
  64.             $('.add-cart').on('click', function(e) {
  65.                 var $form = $(this).parents('li').find('form');
  66.                 // 個数フォームのチェック
  67.                 var $quantity = $form.parent().find('.quantity');
  68.                 if ($quantity.val() < 1) {
  69.                     $quantity[0].setCustomValidity('{{ '1以上で入力してください。'|trans }}');
  70.                     setTimeout(function() {
  71.                         loadingOverlay('hide');
  72.                     }, 100);
  73.                     return true;
  74.                 } else {
  75.                     $quantity[0].setCustomValidity('');
  76.                 }
  77.                 e.preventDefault();
  78.                 $.ajax({
  79.                     url: $form.attr('action'),
  80.                     type: $form.attr('method'),
  81.                     data: $form.serialize(),
  82.                     dataType: 'json',
  83.                     beforeSend: function(xhr, settings) {
  84.                         // Buttonを無効にする
  85.                         $('.add-cart').prop('disabled', true);
  86.                     }
  87.                 }).done(function(data) {
  88.                     // レスポンス内のメッセージをalertで表示
  89.                     $.each(data.messages, function() {
  90.                         $('#ec-modal-header').html(this);
  91.                     });
  92.                     $('.ec-modal').show()
  93.                     // カートブロックを更新する
  94.                     $.ajax({
  95.                         url: '{{ url('block_cart') }}',
  96.                         type: 'GET',
  97.                         dataType: 'html'
  98.                     }).done(function(html) {
  99.                         $('.ec-headerRole__cart').html(html);
  100.                     });
  101.                 }).fail(function(data) {
  102.                     alert('{{ 'カートへの追加に失敗しました。'|trans }}');
  103.                 }).always(function(data) {
  104.                     // Buttonを有効にする
  105.                     $('.add-cart').prop('disabled', false);
  106.                 });
  107.             });
  108.         });
  109.         $('.ec-modal-wrap').on('click', function(e) {
  110.             // モーダル内の処理は外側にバブリングさせない
  111.             e.stopPropagation();
  112.         });
  113.         $('.ec-modal-overlay, .ec-modal, .ec-modal-close, .ec-inlineBtn--cancel').on('click', function() {
  114.             $('.ec-modal').hide()
  115.         });
  116.     </script>
  117. {% endblock %}
  118. {% block main %}
  119.     {% if search_form.category_id.vars.errors|length > 0 %}
  120.         <div class="ec-searchnavRole">
  121.             <p class="errormsg text-danger">{{ 'ご指定のカテゴリは存在しません'|trans }}</p>
  122.         </div>
  123.     {% else %}
  124.         <div class="ec-searchnavRole">
  125.             <form name="form1" id="form1" method="get" action="?">
  126.                 {% for item in search_form %}
  127.                     <input type="hidden" id="{{ item.vars.id }}"
  128.                            name="{{ item.vars.full_name }}"
  129.                            {% if item.vars.value is not empty %}value="{{ item.vars.value }}" {% endif %}/>
  130.                 {% endfor %}
  131.             </form>
  132.             <div class="ec-searchnavRole__topicpath">
  133.                 <ol class="ec-topicpath">
  134.                     <li class="ec-topicpath__item"><a href="{{ url('product_list') }}">{{ '全て'|trans }}</a>
  135.                     </li>
  136.                     {% if Category is not null %}
  137.                         {% for Path in Category.path %}
  138.                             <li class="ec-topicpath__divider">|</li>
  139.                             <li class="ec-topicpath__item{% if loop.last %}--active{% endif %}"><a
  140.                                         href="{{ url('product_list') }}?category_id={{ Path.id }}">{{ Path.name }}</a>
  141.                             </li>
  142.                         {% endfor %}
  143.                     {% endif %}
  144.                     {% if search_form.vars.value and search_form.vars.value.name %}
  145.                         <li class="ec-topicpath__divider">|</li>
  146.                         <li class="ec-topicpath__item">{{ '「%name%」の検索結果'|trans({ '%name%': search_form.vars.value.name }) }}</li>
  147.                     {% endif %}
  148.                 </ol>
  149.             </div>
  150.             <div class="ec-searchnavRole__infos">
  151.                 <div class="ec-searchnavRole__counter">
  152.                     {% if pagination.totalItemCount > 0 %}
  153.                         {{ '<span class="ec-font-bold">%count%件</span><span>のお礼の品が見つかりました</span>'|trans({ '%count%': pagination.totalItemCount })|raw }}
  154.                     {% else %}
  155.                         <span>{{ 'お探しの商品は見つかりませんでした'|trans }}</span>
  156.                     {% endif %}
  157.                 </div>
  158.                 {% if pagination.totalItemCount > 0 %}
  159.                     <div class="ec-searchnavRole__actions">
  160.                         <div class="ec-select">
  161.                             {{ form_widget(disp_number_form, {'id': '', 'attr': {'class': 'disp-number'}}) }}
  162.                             {{ form_widget(order_by_form, {'id': '', 'attr': {'class': 'order-by'}}) }}
  163.                         </div>
  164.                     </div>
  165.                 {% endif %}
  166.             </div>
  167.         </div>
  168.         {% if pagination.totalItemCount > 0 %}
  169.             <div class="ec-shelfRole">
  170.                 <ul class="ec-shelfGrid">
  171.                     {% for Product in pagination %}
  172.                         <li class="ec-shelfGrid__item">
  173.                             <a href="{{ url('product_detail', {'id': Product.id}) }}">
  174.                                 <p class="ec-shelfGrid__item-image">
  175.                                     <img src="{{ asset(Product.main_list_image|no_image_product, 'save_image') }}" alt="{{ Product.name }}" loading="lazy">
  176.                                 </p>
  177.                                 <p>{{ Product.name }}</p>
  178.                                 {% if Product.description_list %}
  179.                                     <p>{{ Product.description_list|raw|nl2br }}</p>
  180.                                 {% endif %}
  181.                                 <p class="price02-default">
  182.                                     {% if Product.hasProductClass %}
  183.                                         {% if Product.getPrice02Min == Product.getPrice02Max %}
  184.                                             <span>寄付金額</span>{{ Product.getPrice02IncTaxMin|number_format }}円
  185.                                         {% else %}
  186.                                             <span>寄付金額</span>{{ Product.getPrice02IncTaxMin|number_format }} ~ {{ Product.getPrice02IncTaxMax|number_format }}円
  187.                                         {% endif %}
  188.                                     {% else %}
  189.                                         <span>寄付金額</span>{{ Product.getPrice02IncTaxMin|number_format }}円
  190.                                     {% endif %}
  191.                                 </p>
  192.                             </a>
  193.                         </li>
  194.                     {% endfor %}
  195.                 </ul>
  196.             </div>
  197.             <div class="ec-modal">
  198.                 <div class="ec-modal-overlay">
  199.                     <div class="ec-modal-wrap">
  200.                         <span class="ec-modal-close"><span class="ec-icon"><img src="{{ asset('assets/icon/cross-dark.svg') }}" alt=""/></span></span>
  201.                         <div id="ec-modal-header" class="text-center">{{ 'カートに追加しました。'|trans }}</div>
  202.                         <div class="ec-modal-box">
  203.                             <div class="ec-role">
  204.                                 <span class="ec-inlineBtn--cancel">{{ 'お買い物を続ける'|trans }}</span>
  205.                                 <a href="{{ url('cart') }}" class="ec-inlineBtn--action">{{ 'カートへ進む'|trans }}</a>
  206.                             </div>
  207.                         </div>
  208.                     </div>
  209.                 </div>
  210.             </div>
  211.             <div class="ec-pagerRole">
  212.                 {% include "pager.twig" with {'pages': pagination.paginationData} %}
  213.             </div>
  214.         {% endif %}
  215.     {% endif %}
  216. {% endblock %}