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 Category.name is defined %}
  88.         {% set categoryName = Category.name %}
  89.         {% else %}
  90.         {% set categoryName = '商品一覧' %}
  91.         {% endif %}
  92.         <section class="p-lower-mv">
  93.             <div class="inner">
  94.                 <h2 class="p-lower-mv-title"><span>{{ categoryName }}</span></h2>
  95.                 <div class="under bread_wrap">
  96.                     <ol itemscope itemtype="https://schema.org/BreadcrumbList">
  97.                         <li itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem">
  98.                             <a itemprop="item" href="{{ url('homepage') }}">
  99.                                 <span class="freight-neo-pro" itemprop="name">TOP</span>
  100.                             </a>
  101.                             <meta itemprop="position" content="1" />
  102.                         </li>
  103.                         <li itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem">
  104.                             <a itemprop="item" href="{{ url('product_list') }}">
  105.                             <span class="freight-neo-pro" itemprop="name">{{ categoryName }}</span>
  106.                             </a>
  107.                             <meta itemprop="position" content="2" />
  108.                         </li>
  109.                     </ol>
  110.                 </div>
  111.                 <!-- /.bread_wrap -->
  112.             </div>
  113.         </section>
  114.     {% if search_form.category_id.vars.errors|length > 0 %}
  115.         <div class="ec-searchnavRole">
  116.             <p class="errormsg text-danger">{{ 'ご指定のカテゴリは存在しません'|trans }}</p>
  117.         </div>
  118.     {% else %}
  119.         <section class="product-search">
  120.             <div class="inner">
  121.                 <form name="form1" id="form1" method="get" action="?">
  122.                     {% for item in search_form %}
  123.                         <input type="hidden" id="{{ item.vars.id }}"
  124.                                 name="{{ item.vars.full_name }}"
  125.                                 {% if item.vars.value is not empty %}value="{{ item.vars.value }}" {% endif %}/>
  126.                     {% endfor %}
  127.                 </form>
  128.                 <!-- <div class="ec-searchnavRole__topicpath">
  129.                     <ol class="ec-topicpath">
  130.                         <li class="ec-topicpath__item"><a href="{{ url('product_list') }}">{{ '全て'|trans }}</a>
  131.                         </li>
  132.                         {% if Category is not null %}
  133.                             {% for Path in Category.path %}
  134.                                 <li class="ec-topicpath__divider">|</li>
  135.                                 <li class="ec-topicpath__item{% if loop.last %}--active{% endif %}"><a
  136.                                             href="{{ url('product_list') }}?category_id={{ Path.id }}">{{ Path.name }}</a>
  137.                                 </li>
  138.                             {% endfor %}
  139.                         {% endif %}
  140.                         {% if search_form.vars.value and search_form.vars.value.name %}
  141.                             <li class="ec-topicpath__divider">|</li>
  142.                             <li class="ec-topicpath__item">{{ '「%name%」の検索結果'|trans({ '%name%': search_form.vars.value.name }) }}</li>
  143.                         {% endif %}
  144.                     </ol>
  145.                 </div> -->
  146.                 <div class="product-search-wrap">
  147.                     <div class="product-search-count">
  148.                         {% if pagination.totalItemCount > 0 %}
  149.                             {{ '<span class="number">%count%</span><span>件の商品が見つかりました</span>'|trans({ '%count%': pagination.totalItemCount })|raw }}
  150.                         {% else %}
  151.                             <span>{{ 'お探しの商品は見つかりませんでした'|trans }}</span>
  152.                         {% endif %}
  153.                     </div>
  154.                     {% if pagination.totalItemCount > 0 %}
  155.                         <div class="product-search-select">
  156.                             {{ form_widget(search_form.disp_number, {'id': 'disp-number', 'attr': {'class': 'disp-number'}}) }}
  157.                             {{ form_widget(search_form.orderby, {'id': 'orderby', 'attr': {'class': 'order-by'}}) }}
  158.                         </div>
  159.                     {% endif %}
  160.                 </div>
  161.             </div>
  162.         </section>
  163.         <section class="product">
  164.         {% if pagination.totalItemCount > 0 %}
  165.             <div class="inner">
  166.                 <ul class="p-product-list">
  167.                     {% for Product in pagination %}
  168.                         <li class="p-product-item">
  169.                             <a href="{{ url('product_detail', {'id': Product.id}) }}">
  170.                                 <div class="product-item-head">
  171.                                     {% if Product.ProductBadge is defined and
  172.                                         Product.ProductBadge is not null and
  173.                                         Product.ProductBadge.name is defined and
  174.                                         Product.ProductBadge.name is not null and
  175.                                         Product.ProductBadge.filename != '' %}
  176.                                     <div class="product-item-badge">
  177.                                         <img
  178.                                             src="{{ asset(Product.ProductBadge.filename|no_image_product, 'save_image') }}"
  179.                                             alt="{{ Product.ProductBadge.name }}">
  180.                                     </div>
  181.                                     {% endif %}
  182.                                     <img src="{{ asset(Product.main_list_image|no_image_product, 'save_image') }}" alt="{{ Product.name }}" {% if loop.index > 5 %} loading="lazy"{% endif %}>
  183.                                 </div>
  184.                                 <div class="product-item-body">
  185.                                     <h3 class="product-item-name">{{ Product.name }}</h3>
  186.                                     {% if Product.description_detail %}
  187.                                     <div class="product-item-desc">{{ Product.description_detail|raw }}</div>
  188.                                     {% endif %}
  189.                                     <p class="product-item-price">
  190.                                         {% if Product.hasProductClass %}
  191.                                             {% if Product.getPrice02Min == Product.getPrice02Max %}
  192.                                                 {{ Product.getPrice02IncTaxMin }}<span>円(税込)</span>
  193.                                             {% else %}
  194.                                                 {{ Product.getPrice02IncTaxMin }} ~ {{ Product.getPrice02IncTaxMax }}<span>円(税込)</span>
  195.                                             {% endif %}
  196.                                         {% else %}
  197.                                             {{ Product.getPrice02IncTaxMin }}<span>円(税込)</span>
  198.                                         {% endif %}
  199.                                     </p>
  200.                                 </div>
  201.                             </a>
  202.                             {% if Product.stock_find %}
  203.                                 {% set form = forms[Product.id] %}
  204.                                 <!-- <form name="form{{ Product.id }}" id="productForm{{ Product.id }}" action="{{ url('product_add_cart', {id:Product.id}) }}" method="post">
  205.                                     <div class="ec-productRole__actions">
  206.                                         {% if form.classcategory_id1 is defined %}
  207.                                             <div class="ec-select">
  208.                                                 {{ form_widget(form.classcategory_id1) }}
  209.                                                 {{ form_errors(form.classcategory_id1) }}
  210.                                             </div>
  211.                                             {% if form.classcategory_id2 is defined %}
  212.                                                 <div class="ec-select">
  213.                                                     {{ form_widget(form.classcategory_id2) }}
  214.                                                     {{ form_errors(form.classcategory_id2) }}
  215.                                                 </div>
  216.                                             {% endif %}
  217.                                         {% endif %}
  218.                                         <div class="ec-numberInput"><span>{{ '数量'|trans }}</span>
  219.                                             {{ form_widget(form.quantity, {'attr': {'class': 'quantity'}}) }}
  220.                                             {{ form_errors(form.quantity) }}
  221.                                         </div>
  222.                                     </div>
  223.                                     {{ form_rest(form) }}
  224.                                 </form>
  225.                                 <div class="ec-productRole__btn">
  226.                                     <button type="submit" class="ec-blockBtn--action add-cart" data-cartid="{{ Product.id }}" form="productForm{{ Product.id }}">
  227.                                         {{ 'カートに入れる'|trans }}
  228.                                     </button>
  229.                                 </div> -->
  230.                             {% else %}
  231.                                 <!-- <div class="ec-productRole__btn">
  232.                                     <button type="button" class="ec-blockBtn--action" disabled="disabled">
  233.                                         {{ 'ただいま品切れ中です。'|trans }}
  234.                                     </button>
  235.                                 </div> -->
  236.                             {% endif %}
  237.                         </li>
  238.                     {% endfor %}
  239.                 </ul>
  240.                 <!-- <div class="ec-modal">
  241.                     <div class="ec-modal-overlay">
  242.                         <div class="ec-modal-wrap">
  243.                             <span class="ec-modal-close"><span class="ec-icon"><img src="{{ asset('assets/icon/cross-dark.svg') }}" alt=""/></span></span>
  244.                             <div id="ec-modal-header" class="text-center">{{ 'カートに追加しました。'|trans }}</div>
  245.                             <div class="ec-modal-box">
  246.                                 <div class="ec-role">
  247.                                     <span class="ec-inlineBtn--cancel">{{ 'お買い物を続ける'|trans }}</span>
  248.                                     <a href="{{ url('cart') }}" class="ec-inlineBtn--action">{{ 'カートへ進む'|trans }}</a>
  249.                                 </div>
  250.                             </div>
  251.                         </div>
  252.                     </div>
  253.                 </div> -->
  254.                 <div class="p-pagination">
  255.                     {% include "pager.twig" with {'pages': pagination.paginationData} %}
  256.                 </div>
  257.             </div>
  258.         {% endif %}
  259.         </section>
  260.     {% endif %}
  261.     {% include 'Block/recommend_product_block.twig' %}
  262.     {% include 'Block/category.twig' %}
  263. {% endblock %}