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

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