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').html(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.                         $('.cart_content').html(html);
  68.                         //固定フッターのバッジ更新
  69.                         const out_html = $($.parseHTML(html));
  70.                         const badge = out_html.find('#head_cartNavi_badge').text();
  71.                         $('#fixed_footer_badge').text(badge);
  72.                     });
  73.                 }).fail(function(data) {
  74.                     alert('{{ 'カートへの追加に失敗しました。'|trans }}');
  75.                 }).always(function(data) {
  76.                     // Buttonを有効にする
  77.                     $('.add-cart').prop('disabled', false);
  78.                 });
  79.             });
  80.         });
  81.         $('.ec-modal-wrap').on('click', function(e) {
  82.             // モーダル内の処理は外側にバブリングさせない
  83.             e.stopPropagation();
  84.         });
  85.         $('.ec-modal-overlay, .ec-modal, .ec-modal-close, .ec-inlineBtn--cancel').on('click', function() {
  86.             $('.ec-modal').hide()
  87.         });
  88.     </script>
  89. {% endblock %}
  90. {% block main %}
  91.     {% if search_form.category_id.vars.errors|length > 0 %}
  92.         <div class="ec-searchnavRole">
  93.             <p class="errormsg text-danger">{{ 'ご指定のカテゴリは存在しません'|trans }}</p>
  94.         </div>
  95.     {% else %}
  96.         <div class="ec-searchnavRole">
  97.             <form name="form1" id="form1" method="get" action="?">
  98.                 {% for item in search_form %}
  99.                     <input type="hidden" id="{{ item.vars.id }}"
  100.                            name="{{ item.vars.full_name }}"
  101.                            {% if item.vars.value is not empty %}value="{{ item.vars.value }}" {% endif %}/>
  102.                 {% endfor %}
  103.             </form>
  104.             <div class="ec-searchnavRole__topicpath">
  105.                 <ol class="ec-topicpath">
  106.                     <li class="ec-topicpath__item"><a href="{{ url('product_list') }}">{{ '全て'|trans }}</a>
  107.                     </li>
  108.                     {% if Category is not null %}
  109.                         {% for Path in Category.path %}
  110.                             <li class="ec-topicpath__divider">|</li>
  111.                             <li class="ec-topicpath__item{% if loop.last %}--active{% endif %}"><a
  112.                                         href="{{ url('product_list') }}?category_id={{ Path.id }}">{{ Path.name }}</a>
  113.                             </li>
  114.                         {% endfor %}
  115.                     {% endif %}
  116.                     {% if search_form.vars.value and search_form.vars.value.name %}
  117.                         <li class="ec-topicpath__divider">|</li>
  118.                         <li class="ec-topicpath__item">{{ '「%name%」の検索結果'|trans({ '%name%': search_form.vars.value.name }) }}</li>
  119.                     {% endif %}
  120.                 </ol>
  121.             </div>
  122.             <div class="ec-searchnavRole__infos">
  123.                 <div class="ec-searchnavRole__counter">
  124.                     {% if pagination.totalItemCount > 0 %}
  125.                         {{ '<span class="ec-font-bold">%count%件</span><span>の商品が見つかりました</span>'|trans({ '%count%': pagination.totalItemCount })|raw }}
  126.                     {% else %}
  127.                         <span>{{ 'お探しの商品は見つかりませんでした'|trans }}</span>
  128.                     {% endif %}
  129.                 </div>
  130.                 {% if pagination.totalItemCount > 0 %}
  131.                     <div class="ec-searchnavRole__actions">
  132.                         <div class="ec-select">
  133.                             {{ form_widget(search_form.disp_number, {'id': '', 'attr': {'class': 'disp-number'}}) }}
  134.                             {{ form_widget(search_form.orderby, {'id': '', 'attr': {'class': 'order-by'}}) }}
  135.                         </div>
  136.                     </div>
  137.                 {% endif %}
  138.             </div>
  139.         </div>
  140.         {% if pagination.totalItemCount > 0 %}
  141.             <div class="ec-shelfRole">
  142.                 <ul class="ec-shelfGrid">
  143.                     {% for Product in pagination %}
  144.                         <li class="ec-shelfGrid__item">
  145.                             <a href="{{ url('product_detail', {'id': Product.id}) }}">
  146.                                 <p class="ec-shelfGrid__item-image">
  147.                                     <img src="{{ asset(Product.main_list_image|no_image_product, 'save_image') }}" alt="{{ Product.name }}" {% if loop.index > 5 %} loading="lazy"{% endif %}>
  148.                                 </p>
  149.                                 <p class="item_name">{{ Product.name }}</p>
  150.                                 {% if Product.description_list %}
  151.                                     <p class="mt01">{{ Product.description_list|raw|nl2br }}</p>
  152.                                 {% endif %}
  153.                             </a>
  154.                             {% if Product.stock_find %}
  155.                                 {% set form = forms[Product.id] %}
  156.                                 <form name="form{{ Product.id }}" id="productForm{{ Product.id }}" action="{{ url('product_add_cart', {id:Product.id}) }}" method="post">
  157.                                     
  158.                                     <div style="display:none;" class="list_price_area">
  159.                                         {% if CustomerRank == false %}
  160.                                         <p class="price02-default">
  161.                                             {% if Product.hasProductClass %}
  162.                                                 {% if Product.getPrice02Min == Product.getPrice02Max %}
  163.                                                     {{ Product.getPrice02IncTaxMin|price }}
  164.                                                 {% else %}
  165.                                                     {{ Product.getPrice02IncTaxMin|price }} ~ {{ Product.getPrice02IncTaxMax|price }}
  166.                                                 {% endif %}
  167.                                             {% else %}
  168.                                                 {{ Product.getPrice02IncTaxMin|price }}
  169.                                             {% endif %}
  170.                                         </p>
  171.                                         {% endif %}
  172.                                         {{ include('Product/customer_price_list.twig') }}
  173.                                     </div>
  174.                                     
  175.                                     <div class="ec-productRole__actions">
  176.                                         {% if form.classcategory_id1 is defined %}
  177.                                             <div class="ec-select">
  178.                                                 {{ form_widget(form.classcategory_id1) }}
  179.                                                 {{ form_errors(form.classcategory_id1) }}
  180.                                             </div>
  181.                                             {% if form.classcategory_id2 is defined %}
  182.                                                 <div class="ec-select">
  183.                                                     {{ form_widget(form.classcategory_id2) }}
  184.                                                     {{ form_errors(form.classcategory_id2) }}
  185.                                                 </div>
  186.                                             {% endif %}
  187.                                         {% endif %}
  188.                                         <div class="ec-numberInput"><span>{{ '数量'|trans }}</span>
  189.                                             {{ form_widget(form.quantity, {'attr': {'class': 'quantity'}}) }}
  190.                                             {{ form_errors(form.quantity) }}
  191.                                         </div>
  192.                                     </div>
  193.                                     {{ form_rest(form) }}
  194.                                     
  195.                                     <div class="ec-productRole__btn">
  196.                                         <button type="submit" class="ec-blockBtn--action add-cart" data-cartid="{{ Product.id }}" form="productForm{{ Product.id }}">
  197.                                             {{ 'カートに入れる'|trans }}
  198.                                         </button>
  199.                                     </div>
  200.                                 </form>
  201.                                 
  202.                             {% else %}
  203.                                 <div class="ec-productRole__btn">
  204.                                     <button type="button" class="ec-blockBtn--action" disabled="disabled">
  205.                                         {{ 'ただいま品切れ中です。'|trans }}
  206.                                     </button>
  207.                                 </div>
  208.                             {% endif %}
  209.                         </li>
  210.                     {% endfor %}
  211.                 </ul>
  212.             </div>
  213.             <div class="ec-modal">
  214.                 <div class="ec-modal-overlay">
  215.                     <div class="ec-modal-wrap">
  216.                         <span class="ec-modal-close"><span class="ec-icon">×</span></span>
  217.                         <div id="ec-modal-header" class="text-center">{{ 'カートに追加しました。'|trans }}</div>
  218.                         <div class="ec-modal-box">
  219.                             <div class="ec-role">
  220.                                 <span class="ec-inlineBtn--cancel">{{ 'お買い物を続ける'|trans }}</span>
  221.                                 <a href="{{ url('cart') }}" class="ec-inlineBtn--action">{{ 'カートへ進む'|trans }}</a>
  222.                             </div>
  223.                         </div>
  224.                     </div>
  225.                 </div>
  226.             </div>
  227.             <div class="ec-pagerRole">
  228.                 {% include "pager.twig" with {'pages': pagination.paginationData} %}
  229.             </div>
  230.         {% endif %}
  231.     {% endif %}
  232. {% endblock %}