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