src/Eccube/Resource/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.                 e.preventDefault();
  36.                 $.ajax({
  37.                     url: $form.attr('action'),
  38.                     type: $form.attr('method'),
  39.                     data: $form.serialize(),
  40.                     dataType: 'json',
  41.                     beforeSend: function(xhr, settings) {
  42.                         // Buttonを無効にする
  43.                         $('.add-cart').prop('disabled', true);
  44.                     }
  45.                 }).done(function(data) {
  46.                     // レスポンス内のメッセージをalertで表示
  47.                     $.each(data.messages, function() {
  48.                         $('#ec-modal-header').html(this);
  49.                     });
  50.                     $('#ec-modal-checkbox').prop('checked', true);
  51.                     // カートブロックを更新する
  52.                     $.ajax({
  53.                         url: '{{ url('block_cart') }}',
  54.                         type: 'GET',
  55.                         dataType: 'html'
  56.                     }).done(function(html) {
  57.                         $('.ec-headerRole__cart').html(html);
  58.                     });
  59.                 }).fail(function(data) {
  60.                     alert('{{ 'カートへの追加に失敗しました。'|trans }}');
  61.                 }).always(function(data) {
  62.                     // Buttonを有効にする
  63.                     $('.add-cart').prop('disabled', false);
  64.                 });
  65.             });
  66.         });
  67.     </script>
  68. {% endblock %}
  69. {% block main %}
  70.     {% if search_form.category_id.vars.errors|length > 0 %}
  71.         <div class="ec-searchnavRole">
  72.             <p class="errormsg text-danger">{{ 'ご指定のカテゴリは存在しません'|trans }}</p>
  73.         </div>
  74.     {% else %}
  75.         <div class="ec-searchnavRole">
  76.             <form name="form1" id="form1" method="get" action="?">
  77.                 {% for item in search_form %}
  78.                     <input type="hidden" id="{{ item.vars.id }}"
  79.                            name="{{ item.vars.full_name }}"
  80.                            {% if item.vars.value is not empty %}value="{{ item.vars.value }}" {% endif %}/>
  81.                 {% endfor %}
  82.             </form>
  83.             <div class="ec-searchnavRole__topicpath">
  84.                 <ol class="ec-topicpath">
  85.                     <li class="ec-topicpath__item"><a href="{{ url('product_list') }}">{{ '全て'|trans }}</a>
  86.                     </li>
  87.                     {% if Category is not null %}
  88.                         {% for Path in Category.path %}
  89.                             <li class="ec-topicpath__divider">|</li>
  90.                             <li class="ec-topicpath__item{% if loop.last %}--active{% endif %}"><a
  91.                                         href="{{ url('product_list') }}?category_id={{ Path.id }}">{{ Path.name }}</a>
  92.                             </li>
  93.                         {% endfor %}
  94.                     {% endif %}
  95.                     {% if search_form.vars.value and search_form.vars.value.name %}
  96.                         <li class="ec-topicpath__divider">|</li>
  97.                         <li class="ec-topicpath__item">{{ '「%name%」の検索結果'|trans({ '%name%': search_form.vars.value.name }) }}</li>
  98.                     {% endif %}
  99.                 </ol>
  100.             </div>
  101.             <div class="ec-searchnavRole__infos">
  102.                 <div class="ec-searchnavRole__counter">
  103.                     {% if pagination.totalItemCount > 0 %}
  104.                         {{ '<span class="ec-font-bold">%count%件</span><span>の商品が見つかりました</span>'|trans({ '%count%': pagination.totalItemCount })|raw }}
  105.                     {% else %}
  106.                         <span>{{ 'お探しの商品は見つかりませんでした'|trans }}</span>
  107.                     {% endif %}
  108.                 </div>
  109.                     {% if pagination.totalItemCount > 0 %}
  110.                         <div class="ec-searchnavRole__actions">
  111.                             <div class="ec-select">
  112.                                 <!-- No input fields needed here -->
  113.                             </div>
  114.                         </div>
  115.                     {% endif %}
  116.             </div>
  117.         </div>
  118.         {% if pagination.totalItemCount > 0 %}
  119.             <div class="ec-shelfRole">
  120.                 <ul class="ec-shelfGrid">
  121.                     {% for Product in pagination %}
  122.                         <li class="panel panel-default ec-shelfGrid__item">
  123.                             <a href="{{ url('product_detail', {'id': Product.id}) }}">
  124.                                 <p class="ec-shelfGrid__item-image">
  125.                                     <img src="{{ asset(Product.main_list_image|no_image_product, 'save_image') }}">
  126.                                 </p>
  127.                                 <p class="product-title-default"><b>{{ Product.name }}</b></p>
  128.                                 {% if Product.description_list %}
  129.                                     <p>{{ Product.description_list|raw|nl2br }}</p>
  130.                                 {% endif %}
  131.                                 <b class="price02-default">
  132.                                     {% if Product.hasProductClass %}
  133.                                         {% if Product.getPrice02Min == Product.getPrice02Max %}
  134.                                             {{ Product.getPrice02IncTaxMin|price }}
  135.                                         {% else %}
  136.                                             {{ Product.getPrice02IncTaxMin|price }} ~ {{ Product.getPrice02IncTaxMax|price }}
  137.                                         {% endif %}
  138.                                     {% else %}
  139.                                         {{ Product.getPrice02IncTaxMin|price }}
  140.                                     {% endif %}
  141.                                 </b>
  142.                             </a>
  143.                             {% if Product.stock_find %}
  144.                                 <div class="ec-productRole__btn">
  145.                                     <a href="{{ path('product_detail', {'id': Product.id}) }}" class="ec-blockBtn--action">
  146.                                         {{ 'この商品を見る'|trans }}
  147.                                     </a>
  148.                                 </div>
  149.                             {% else %}
  150.                                 <div class="ec-productRole__btn">
  151.                                     <button type="button" class="ec-blockBtn--action" disabled="disabled">
  152.                                         {{ '品切れ中です'|trans }}
  153.                                     </button>
  154.                                 </div>
  155.                             {% endif %}
  156.                         </li>
  157.                     {% endfor %}
  158.                 </ul>
  159.             </div>
  160.             <div class="ec-modal">
  161.                 <input type="checkbox" id="ec-modal-checkbox" class="checkbox">
  162.                 <div class="ec-modal-overlay">
  163.                     <label for="ec-modal-checkbox" class="ec-modal-overlay-close"></label>
  164.                     <div class="ec-modal-wrap">
  165.                         <label for="ec-modal-checkbox" class="ec-modal-close"><span class="ec-icon"><img src="{{ asset('assets/icon/cross-dark.svg') }}" alt=""/></span></label>
  166.                         <div id="ec-modal-header" class="text-center">{{ 'カートに追加しました。'|trans }}</div>
  167.                         <div class="ec-modal-box">
  168.                             <div class="ec-role">
  169.                                 <label for="ec-modal-checkbox" class="ec-inlineBtn--cancel">{{ 'お買い物を続ける'|trans }}</label>
  170.                                 <a href="{{ url('cart') }}" class="ec-inlineBtn--action">{{ 'カートへ進む'|trans }}</a>
  171.                             </div>
  172.                         </div>
  173.                     </div>
  174.                 </div>
  175.             </div>
  176.             <div class="ec-pagerRole">
  177.                 {% include "pager.twig" with {'pages': pagination.paginationData} %}
  178.             </div>
  179.         {% endif %}
  180.     {% endif %}
  181. {% endblock %}