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').html(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-overlay, .ec-modal .ec-inlineBtn--cancel').on('click', function() {
  78.             $('.ec-modal').hide()
  79.         });
  80.     </script>
  81. {% endblock %}
  82. {% block main %}
  83.     {% if search_form.category_id.vars.errors|length > 0 %}
  84.         <div class="ec-searchnavRole">
  85.             <p class="errormsg text-danger">{{ 'ご指定のカテゴリは存在しません'|trans }}</p>
  86.         </div>
  87.     {% else %}
  88.         <div class="ec-searchnavRole">
  89.             <div class="ec-pageHeader product_list_title01">
  90.                 <h1>{{ '商品を探す'|trans }}</h1>
  91.             </div>
  92.             <form name="form1" id="form1" method="get" action="?">
  93.                 {% for item in search_form %}
  94.                     <input type="hidden" id="{{ item.vars.id }}"
  95.                            name="{{ item.vars.full_name }}"
  96.                            {% if item.vars.value is not empty %}value="{{ item.vars.value }}" {% endif %}/>
  97.                 {% endfor %}
  98.             </form>
  99.             <div class="ec-searchnavRole__topicpath">
  100.                 <ol class="ec-topicpath">
  101.                     <li class="ec-topicpath__item"><a href="{{ url('product_list') }}">{{ '全て'|trans }}</a>
  102.                     </li>
  103.                     {% if Category is not null %}
  104.                         {% for Path in Category.path %}
  105.                             <li class="ec-topicpath__divider">|</li>
  106.                             <li class="ec-topicpath__item{% if loop.last %}--active{% endif %}"><a
  107.                                         href="{{ url('product_list') }}?category_id={{ Path.id }}">{{ Path.name }}</a>
  108.                             </li>
  109.                         {% endfor %}
  110.                     {% endif %}
  111.                     {% if search_form.vars.value and search_form.vars.value.name %}
  112.                         <li class="ec-topicpath__divider">|</li>
  113.                         <li class="ec-topicpath__item">{{ '「%name%」の検索結果'|trans({ '%name%': search_form.vars.value.name }) }}</li>
  114.                     {% endif %}
  115.                 </ol>
  116.             </div>
  117.             <div class="ec-searchnavRole__infos">
  118.                 <div class="ec-searchnavRole__counter">
  119.                     {% if pagination.totalItemCount > 0 %}
  120.                         {{ '<span class="ec-font-bold">%count%件</span><span>の商品が見つかりました</span>'|trans({ '%count%': pagination.totalItemCount })|raw }}
  121.                     {% else %}
  122.                         <span>{{ 'お探しの商品は見つかりませんでした'|trans }}</span>
  123.                     {% endif %}
  124.                 </div>
  125.                 {% if pagination.totalItemCount > 0 %}
  126.                     <div class="ec-searchnavRole__actions">
  127.                         <div class="ec-select">
  128.                             {{ form_widget(disp_number_form, {'id': '', 'attr': {'class': 'disp-number'}}) }}
  129.                             {{ form_widget(order_by_form, {'id': '', 'attr': {'class': 'order-by'}}) }}
  130.                         </div>
  131.                     </div>
  132.                 {% endif %}
  133.             </div>
  134.         </div>
  135.         {% if pagination.totalItemCount > 0 %}
  136.             <div class="ec-shelfRole">
  137.                 <ul class="ec-shelfGrid product_listul01">
  138.                     {% for Product in pagination %}
  139.                         <li class="ec-shelfGrid__item">
  140.                             <a href="{{ url('product_detail', {'id': Product.id}) }}">
  141.                                 <p class="ec-shelfGrid__item-image">
  142.                                     <img src="{{ asset(Product.main_list_image|no_image_product, 'save_image') }}">
  143.                                 </p>
  144.                                 <h3 class="product_listul01_title">{{ Product.name }}</h3>
  145.                                 {% if Product.description_list %}
  146.                                     <p>{{ Product.description_list|raw|nl2br }}</p>
  147.                                 {% endif %}
  148.                                 <p class="price02-default product_listul01_price">
  149.                                     {% if Product.hasProductClass %}
  150.                                         {% if Product.getPrice02Min == Product.getPrice02Max %}
  151.                                             {{ Product.getPrice02IncTaxMin|price }}
  152.                                         {% else %}
  153.                                             {{ Product.getPrice02IncTaxMin|price }} ~ {{ Product.getPrice02IncTaxMax|price }}
  154.                                         {% endif %}
  155.                                     {% else %}
  156.                                         {{ Product.getPrice02IncTaxMin|price }}
  157.                                     {% endif %}
  158.                                 </p>
  159.                             </a>
  160.                             {% if Product.stock_find %}
  161.                                 {% set form = forms[Product.id] %}
  162.                                 <form name="form{{ Product.id }}" id="productForm{{ Product.id }}" action="{{ url('product_add_cart', {id:Product.id}) }}" method="post">
  163.                                     <div class="ec-productRole__actions">
  164.                                         {% if form.classcategory_id1 is defined %}
  165.                                             <div class="ec-select">
  166.                                                 {{ form_widget(form.classcategory_id1) }}
  167.                                                 {{ form_errors(form.classcategory_id1) }}
  168.                                             </div>
  169.                                             {% if form.classcategory_id2 is defined %}
  170.                                                 <div class="ec-select">
  171.                                                     {{ form_widget(form.classcategory_id2) }}
  172.                                                     {{ form_errors(form.classcategory_id2) }}
  173.                                                 </div>
  174.                                             {% endif %}
  175.                                         {% endif %}
  176.                                         <div class="ec-numberInput"><span>{{ '数量'|trans }}</span>
  177.                                             {{ form_widget(form.quantity, {'attr': {'class': 'quantity'}}) }}
  178.                                             {{ form_errors(form.quantity) }}
  179.                                         </div>
  180.                                     </div>
  181.                                     {{ form_rest(form) }}
  182.                                 </form>
  183.                                 <div class="ec-productRole__btn">
  184.                                     <button type="submit" class="ec-blockBtn--action add-cart" data-cartid="{{ Product.id }}" form="productForm{{ Product.id }}">
  185.                                         <!--<img src="/html/user_data/assets/img/common/cart.png" class="max_img" alt="">-->
  186.                                         <!--{{ 'カートに入れる'|trans }}-->
  187.                                     </button>
  188.                                 </div>
  189.                             {% else %}
  190.                                 <div class="ec-productRole__btn">
  191.                                     <button type="button" class="ec-blockBtn--action" disabled="disabled">
  192.                                         {{ 'ただいま品切れ中です。'|trans }}
  193.                                     </button>
  194.                                 </div>
  195.                             {% endif %}
  196.                         </li>
  197.                     {% endfor %}
  198.                 </ul>
  199.             </div>
  200.             <div class="ec-modal">
  201.                 <div class="ec-modal-overlay">
  202.                     <div class="ec-modal-wrap">
  203.                         <span class="ec-modal-close"><span class="ec-icon"><img src="{{ asset('assets/icon/cross-dark.svg') }}" alt=""/></span></span>
  204.                         <div id="ec-modal-header" class="text-center">{{ 'カートに追加しました。'|trans }}</div>
  205.                         <div class="ec-modal-box">
  206.                             <div class="ec-role">
  207.                                 <span class="ec-inlineBtn--cancel">{{ 'お買い物を続ける'|trans }}</span>
  208.                                 <a href="{{ url('cart') }}" class="ec-inlineBtn--action">{{ 'カートへ進む'|trans }}</a>
  209.                             </div>
  210.                         </div>
  211.                     </div>
  212.                 </div>
  213.             </div>
  214.             <div class="ec-pagerRole">
  215.                 {% include "pager.twig" with {'pages': pagination.paginationData} %}
  216.             </div>
  217.         {% endif %}
  218.     {% endif %}
  219. {% endblock %}