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.         $('#category_select').on('change', function() {
  85.         // 遷移先URL取得
  86.         var url = $(this).val();
  87.         // URLが取得できていればページ遷移
  88.         if(url != '') {
  89.             location.href = url;
  90.         }
  91.       });
  92.     </script>
  93. {% endblock %}
  94. {% block main %}
  95. {%  set Categories = repository('Eccube\\Entity\\Category').findAll() %}
  96. {% if Category.name is defined %}
  97. {% set categoryName = Category.name %}
  98. {% else %}
  99. {% set categoryName = '商品一覧' %}
  100. {% endif %}
  101. <section class="l-lower-mv product-mv">
  102.   <div class="inner l-lower-mv__inner">
  103.     <h1 class="l-lower-mv__title">Line up<span class="l-lower-mv__subtitle">商品一覧</span></h1>
  104.   </div>
  105. </section>
  106. <section class="product">
  107.   <div class="inner product__inner">
  108.     <div class="l-breadcrumb">
  109.       <ul itemscope itemtype="https://schema.org/BreadcrumbList" class="l-breadcrumb__list">
  110.         <li itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem" class="l-breadcrumb__item">
  111.           <a itemprop="item" href="{{ url('homepage') }}" class="l-breadcrumb__link">
  112.             <span class="freight-neo-pro" itemprop="name">TOP</span>
  113.           </a>
  114.           <meta itemprop="position" content="1" />
  115.         </li>
  116.         <li itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem" class="l-breadcrumb__item">
  117.           <a itemprop="item" href="{{ url('product_list') }}" class="l-breadcrumb__link">
  118.             <span class="freight-neo-pro" itemprop="name">{{ categoryName }}</span>
  119.           </a>
  120.           <meta itemprop="position" content="2" />
  121.         </li>
  122.       </ul>
  123.     </div>
  124.     <div class="product__container">
  125.       <article class="product__article">
  126.         {% if search_form.category_id.vars.errors|length > 0 %}
  127.         <div class="ec-searchnavRole">
  128.           <p class="errormsg text-danger">{{ 'ご指定のカテゴリは存在しません'|trans }}</p>
  129.         </div>
  130.         {% else %}
  131.         <div class="product__search">
  132.           <form name="form1" id="form1" method="get" action="?">
  133.             {% for item in search_form %}
  134.             <input type="hidden" id="{{ item.vars.id }}" name="{{ item.vars.full_name }}" {% if item.vars.value is not
  135.               empty %} value="{{ item.vars.value }}" {% endif %} />
  136.             {% endfor %}
  137.           </form>
  138.           <div class="product__search-top">
  139.             {% if Category is not null %}
  140.             {# {% for Path in Category.path %} #}
  141.               {# {% if Category.parent == null %} #}
  142.               <h2 class="product__search-heading">{{ Category.name }}</h2>
  143.               {# {% else %} #}
  144.               {# <h2 class="product__search-heading">{{ Category.Parent.name }} {{ Category.name }}</h2> #}
  145.               {# {% endif %} #}
  146.             {# {% endfor %} #}
  147.             {% else %}
  148.             <h2 class="product__search-heading">{{ '全て'|trans }}</h2>
  149.             {% endif %}
  150.             {% if pagination.totalItemCount > 0 %}
  151.             <div class="product__search-select-wrap">
  152.               <select name="category_select" id="category_select" class="form-select -category">
  153.                 <option value="{{ url('product_list') }}">全ての商品</option>
  154.                 {% for Category in Categories %}
  155.                   {% set ParentCategory = Category %}
  156.                   {% for ChildCategory in ParentCategory.children %}
  157.                 <option value="{{ url('product_list') }}?category_id={{ParentCategory.id}}">{{ParentCategory.name}}</option>
  158.                 <option value="{{ url('product_list') }}?category_id={{ChildCategory.id}}">&emsp;{{ChildCategory.name}}</option>
  159.                   {% endfor %}
  160.                 {% endfor %}
  161.               </select>
  162.               {{ form_widget(search_form.disp_number, {'id': '', 'attr': {'class': 'disp-number'}}) }}
  163.               {{ form_widget(search_form.orderby, {'id': '', 'attr': {'class': 'order-by'}}) }}
  164.             </div>
  165.             {% endif %}
  166.           </div>
  167.           <div class="product__search-bottom">
  168.             <div class="product__search-counter">
  169.               {% if pagination.totalItemCount > 0 %}
  170.               {{ '<span class="product__search-counter--bold">%count%</span><span>件の商品が見つかりました</span>'|trans({ '%count%':
  171.               pagination.totalItemCount })|raw }}
  172.               {% else %}
  173.               <span>{{ 'お探しの商品は見つかりませんでした'|trans }}</span>
  174.               {% endif %}
  175.             </div>
  176.           </div>
  177.         </div>
  178.         {% if pagination.totalItemCount > 0 %}
  179.         <div class="product__wrap">
  180.           <ul class="product__list">
  181.             {% for Product in pagination %}
  182.             <li class="product__item">
  183.               <a href="{{ url('product_detail', {'id': Product.id}) }}" class="product__item-link">
  184.                 <picture class="product__item-image">
  185.                   <img src="{{ asset(Product.main_list_image|no_image_product, 'save_image') }}" alt="{{ Product.name }}"
  186.                     {% if loop.index> 5 %} loading="lazy" {% endif %}>
  187.                 </picture>
  188.                 <p class="product__item-name">{{ Product.name }}</p>
  189.                 <!-- {% if Product.description_list %}
  190.                 <p>{{ Product.description_list|raw|nl2br }}</p>
  191.                 {% endif %} -->
  192.                 <p class="product__item-price">
  193.                   {% if Product.hasProductClass %}
  194.                   {% if Product.getPrice02Min == Product.getPrice02Max %}
  195.                   {{ Product.getPrice02IncTaxMin|price }}<span>(税込)</span>
  196.                   {% else %}
  197.                   {{ Product.getPrice02IncTaxMin|price }}
  198.                   ~
  199.                   {{ Product.getPrice02IncTaxMax|price }}<span>(税込)</span>
  200.                   {% endif %}
  201.                   {% else %}
  202.                   {{ Product.getPrice02IncTaxMin|price }}<span>(税込)</span>
  203.                   {% endif %}
  204.                 </p>
  205.                 <ul class="p-tags product__tags">
  206.                 {% for Tag in Product.Tags %}
  207.                   <li class="p-tag">{{Tag.name}}</li>
  208.                 {% endfor %}
  209.                 </ul>
  210.               </a>
  211.               {% if Product.stock_find %}
  212.               {% set form = forms[Product.id] %}
  213.               <!-- <form name="form{{ Product.id }}" id="productForm{{ Product.id }}"
  214.                 action="{{ url('product_add_cart', {id:Product.id}) }}" method="post">
  215.                 <div class="ec-productRole__actions">
  216.                   {% if form.classcategory_id1 is defined %}
  217.                   <div class="ec-select">
  218.                     {{ form_widget(form.classcategory_id1) }}
  219.                     {{ form_errors(form.classcategory_id1) }}
  220.                   </div>
  221.                   {% if form.classcategory_id2 is defined %}
  222.                   <div class="ec-select">
  223.                     {{ form_widget(form.classcategory_id2) }}
  224.                     {{ form_errors(form.classcategory_id2) }}
  225.                   </div>
  226.                   {% endif %}
  227.                   {% endif %}
  228.                   <div class="ec-numberInput">
  229.                     <span>{{ '数量'|trans }}</span>
  230.                     {{ form_widget(form.quantity, {'attr': {'class': 'quantity'}}) }}
  231.                     {{ form_errors(form.quantity) }}
  232.                   </div>
  233.                 </div>
  234.                 {{ form_rest(form) }}
  235.               </form> -->
  236.               <!-- <div class="ec-productRole__btn">
  237.                 <button type="submit" class="ec-blockBtn--action add-cart" data-cartid="{{ Product.id }}"
  238.                   form="productForm{{ Product.id }}">
  239.                   {{ 'カートに入れる'|trans }}
  240.                 </button>
  241.               </div> -->
  242.               {% else %}
  243.               <!-- <div class="ec-productRole__btn">
  244.                 <button type="button" class="ec-blockBtn--action" disabled="disabled">
  245.                   {{ 'ただいま品切れ中です。'|trans }}
  246.                 </button>
  247.               </div> -->
  248.               {% endif %}
  249.             </li>
  250.             {% endfor %}
  251.           </ul>
  252.         </div>
  253.         <!-- <div class="ec-modal">
  254.           <div class="ec-modal-overlay">
  255.             <div class="ec-modal-wrap">
  256.               <span class="ec-modal-close">
  257.                 <span class="ec-icon"><img src="{{ asset('assets/icon/cross-dark.svg') }}" alt="" /></span>
  258.               </span>
  259.               <div id="ec-modal-header" class="text-center">{{ 'カートに追加しました。'|trans }}</div>
  260.               <div class="ec-modal-box">
  261.                 <div class="ec-role">
  262.                   <span class="ec-inlineBtn--cancel">{{ 'お買い物を続ける'|trans }}</span>
  263.                   <a href="{{ url('cart') }}" class="ec-inlineBtn--action">{{ 'カートへ進む'|trans }}</a>
  264.                 </div>
  265.               </div>
  266.             </div>
  267.           </div>
  268.         </div> -->
  269.         <div class="ec-pagerRole">
  270.           {% include "pager.twig" with {'pages': pagination.paginationData} %}
  271.         </div>
  272.         {% endif %}
  273.         {% endif %}
  274.       </article>
  275.       <sidebar class="product__sidebar">
  276.         <div class="product__sidebar-wrap">
  277.         {% for Category in Categories %}
  278.           {% set ParentCategory = Category %}
  279.           {% if ParentCategory.parent == null %}
  280.           <ul class="product__sidebar-list">
  281.             <li class="product__sidebar-item product__sidebar-item--parent">
  282.               <a href="{{ url('product_list') }}?category_id={{ParentCategory.id}}" class="product__sidebar-link">{{ParentCategory.name}}</a>
  283.             </li>
  284.             {% for ChildCategory in ParentCategory.children %}
  285.             <li class="product__sidebar-item">
  286.               <a href="{{ url('product_list') }}?category_id={{ChildCategory.id}}" class="product__sidebar-link">{{ ChildCategory.name }}</a>
  287.             </li>
  288.             {% endfor %}
  289.           </ul>
  290.           {% endif %}
  291.         {% endfor %}
  292.         </div>
  293.       </sidebar>
  294.     </div>
  295.   </div>
  296. </section>
  297. <!-- /.product -->
  298. {% endblock %}