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.     <link rel="stylesheet" href="{{ asset('assets/css/productlist.css', 'user_data') }}">
  12. {% endblock %}
  13. {% block javascript %}
  14.     <script>
  15.         eccube.productsClassCategories = {
  16.             {% for Product in pagination %}
  17.             "{{ Product.id|escape('js') }}": {{ class_categories_as_json(Product)|raw }}{% if loop.last == false %}, {% endif %}
  18.             {% endfor %}
  19.         };
  20.         $(function() {
  21.             // 表示件数を変更
  22.             $('.disp-number').change(function() {
  23.                 var dispNumber = $(this).val();
  24.                 $('#disp_number').val(dispNumber);
  25.                 $('#pageno').val(1);
  26.                 $("#form1").submit();
  27.             });
  28.             // 並び順を変更
  29.             $('.order-by').change(function() {
  30.                 var orderBy = $(this).val();
  31.                 $('#orderby').val(orderBy);
  32.                 $('#pageno').val(1);
  33.                 $("#form1").submit();
  34.             });
  35.             $('.add-cart').on('click', function(e) {
  36.                 var $form = $(this).parents('li').find('form');
  37.                 // 個数フォームのチェック
  38.                 var $quantity = $form.parent().find('.quantity');
  39.                 if ($quantity.val() < 1) {
  40.                     $quantity[0].setCustomValidity('{{ '1以上で入力してください。'|trans }}');
  41.                     setTimeout(function() {
  42.                         loadingOverlay('hide');
  43.                     }, 100);
  44.                     return true;
  45.                 } else {
  46.                     $quantity[0].setCustomValidity('');
  47.                 }
  48.                 e.preventDefault();
  49.                 $.ajax({
  50.                     url: $form.attr('action'),
  51.                     type: $form.attr('method'),
  52.                     data: $form.serialize(),
  53.                     dataType: 'json',
  54.                     beforeSend: function(xhr, settings) {
  55.                         // Buttonを無効にする
  56.                         $('.add-cart').prop('disabled', true);
  57.                     }
  58.                 }).done(function(data) {
  59.                     // レスポンス内のメッセージをalertで表示
  60.                     $.each(data.messages, function() {
  61.                         $('#ec-modal-header').text(this);
  62.                     });
  63.                     //$('.ec-modal').show()
  64.                     $('.ec-modal').fadeIn(800);
  65.                     scrollPos = $(window).scrollTop();
  66.                     $('body').addClass('have_ec-modal').css('top',-scrollPos + 'px');
  67.                     // カートブロックを更新する
  68.                     $.ajax({
  69.                         url: '{{ url('block_cart') }}',
  70.                         type: 'GET',
  71.                         dataType: 'html'
  72.                     }).done(function(html) {
  73.                         $('.ec-headerRole__cart').html(html);
  74.                     });
  75.                 }).fail(function(data) {
  76.                     alert('{{ 'カートへの追加に失敗しました。'|trans }}');
  77.                 }).always(function(data) {
  78.                     // Buttonを有効にする
  79.                     $('.add-cart').prop('disabled', false);
  80.                 });
  81.             });
  82.         });
  83.         $('.ec-modal-wrap').on('click', function(e) {
  84.             // モーダル内の処理は外側にバブリングさせない
  85.             e.stopPropagation();
  86.         });
  87.         $('.ec-modal-overlay, .ec-modal, .ec-modal-close, .ec-inlineBtn--cancel').on('click', function() {
  88.             //$('.ec-modal').hide()
  89.             $('.ec-modal').fadeOut(800)
  90.             $('body').removeClass('have_ec-modal').css('top',0 + 'px');
  91.             window.scrollTo( 0 , scrollPos );
  92.         });
  93.     </script>
  94.     <script>
  95.     $(function() {
  96.         $('.form-control').each(function() {
  97.             var el  = $(this);
  98.             var add = $('.spinner-add');
  99.             var sub = $('.spinner-sub');
  100.     // substract
  101.     el.parent().on('click', '.spinner-sub', function() {
  102.         if (el.val() > parseInt(el.attr('min'))) {
  103.         el.val(function(i, oldval) {
  104.             return --oldval;
  105.         });
  106.         }
  107.     // disabled
  108.     if (el.val() == parseInt(el.attr('min'))) {
  109.         el.prev(sub).addClass('disabled');
  110.     }
  111.     if (el.val() < parseInt(el.attr('max'))) {
  112.         el.next(add).removeClass('disabled');
  113.     }
  114.     });
  115.     // increment
  116.     el.parent().on('click', '.spinner-add', function() {
  117.         el.val(function(i, oldval) {
  118.           return ++oldval;
  119.         });
  120.       // disabled
  121.       if (el.val() > parseInt(el.attr('min'))) {
  122.         el.prev(sub).removeClass('disabled');
  123.       }
  124.       if (el.val() == parseInt(el.attr('max'))) {
  125.         el.next(add).addClass('disabled');
  126.       }
  127.     });
  128.   });
  129. });
  130. </script>
  131. {% endblock %}
  132. {% block main %}
  133.     {% if search_form.category_id.vars.errors|length > 0 %}
  134.         <div class="ec-searchnavRole">
  135.             <p class="errormsg text-danger">{{ 'ご指定のカテゴリは存在しません'|trans }}</p>
  136.         </div>
  137.     {% else %}
  138.         <div class="ec-searchnavRole">
  139.             <form name="form1" id="form1" method="get" action="?">
  140.                 {% for item in search_form %}
  141.                     <input type="hidden" id="{{ item.vars.id }}"
  142.                            name="{{ item.vars.full_name }}"
  143.                            {% if item.vars.value is not empty %}value="{{ item.vars.value }}" {% endif %}/>
  144.                 {% endfor %}
  145.             </form>
  146.             {% if Category is not null %}
  147.                 {% for Path in Category.path %}
  148.                     {% if loop.last %}
  149.                         <h1>{{ Path.name }}</h1>
  150.                     {% endif %}
  151.                 {% endfor %}
  152.             {% else %}
  153.                 {% if app.request.get('name') != "" %}
  154.                     <h1>{{app.request.get('name')}}</h1>
  155.                 {% else %}
  156.                     <h1>宇宙グッズ一覧</h1>
  157.                 {% endif %}
  158.             {% endif %}
  159.             <div class="ec-searchnavRole__infos">
  160.                 {% if pagination.totalItemCount > 0 %}
  161.                 {{ '<div class="product_count"><span>%count%</span>件</div>'|trans({ '%count%': pagination.totalItemCount })|raw }}
  162.                     <div class="ec-select">
  163.                         {{ form_widget(search_form.orderby, {'id': '', 'attr': {'class': 'order-by'}}) }}
  164.                     </div>
  165.                 {#
  166.                 {% else %}
  167.                     <div class="product_count">{{ '0件'|trans }}</div>
  168.                 #}
  169.                 {% endif %}
  170.             </div>
  171.         </div>
  172.         
  173.         {% if Category is defined and Category is not null and attribute(Category, 'file_name') is defined %}
  174.         <div class="apg_category_content">
  175.             {% if Category.file_name %}
  176.             <div class="apg_category_image" style="background-image:url({{ asset('rich_category/'~Category.file_name,'save_image') }});"></div>
  177.             {% endif %}
  178.             {% if Category.content %}
  179.             <div class="apg_category_description">
  180.                 {{ Category.content|raw|nl2br }}
  181.             </div>
  182.             {% endif %}
  183.         </div>
  184.         {% endif %}
  185.         
  186.         {% if pagination.totalItemCount > 0 %}
  187.             <div class="ec-shelfRole">
  188.                 <ul class="ec-shelfGrid">
  189.                     {% for Product in pagination %}
  190.                         <li class="ec-shelfGrid__item">
  191.                             <a href="{{ url('product_detail', {'id': Product.id}) }}">
  192.                                 <div class="item_img"><img src="{{ asset(Product.main_list_image|no_image_product, 'save_image') }}" alt="{{ Product.name }}" {% if loop.index > 5 %} loading="lazy"{% endif %}></div>
  193.                                 <p class="item_name">{{ Product.name }}</p>
  194.                                 {% if Product.hasProductClass %}
  195.                                     {% if Product.getPrice02Min == Product.getPrice02Max %}
  196.                                         <p class="price02-default">{{ Product.getPrice02IncTaxMin|price }}</p>
  197.                                     {% else %}
  198.                                         <p class="price02-default price_multiple">{{ Product.getPrice02IncTaxMin|price }}~{{ Product.getPrice02IncTaxMax|price }}</p>
  199.                                     {% endif %}
  200.                                 {% else %}
  201.                                     <p class="price02-default">{{ Product.getPrice02IncTaxMin|price }}</p>
  202.                                 {% endif %}
  203.                             </a>
  204.                             {% if Product.stock_find %}
  205.                                 {% set form = forms[Product.id] %}
  206.                                 <form name="form{{ Product.id }}" id="productForm{{ Product.id }}" action="{{ url('product_add_cart', {id:Product.id}) }}" method="post">
  207.                                     <div class="ec-productRole__actions">
  208.                                         {% if form.classcategory_id1 is defined %}
  209.                                             <div class="ec-select">
  210.                                                 {{ form_widget(form.classcategory_id1) }}
  211.                                                 {{ form_errors(form.classcategory_id1) }}
  212.                                             </div>
  213.                                             {% if form.classcategory_id2 is defined %}
  214.                                                 <div class="ec-select">
  215.                                                     {{ form_widget(form.classcategory_id2) }}
  216.                                                     {{ form_errors(form.classcategory_id2) }}
  217.                                                 </div>
  218.                                             {% endif %}
  219.                                         {% endif %}
  220.                                         <div class="ec-numberInput">
  221.                                             <div class="number_wrap">
  222.                                                 <span class="spinner-sub disabled"><i class="fas fa-minus-circle"></i></span>
  223.                                                 {{ form_widget(form.quantity, {'attr': {'class': 'quantity'}}) }}
  224.                                                 {{ form_errors(form.quantity) }}
  225.                                                 <span class="spinner-add"><i class="fas fa-plus-circle"></i></span>
  226.                                             </div>
  227.                                         </div>
  228.                                     </div>
  229.                                     {{ form_rest(form) }}
  230.                                 </form>
  231.                                 <div class="ec-productRole__btn">
  232.                                     <button type="submit" class="ec-blockBtn--action add-cart" data-cartid="{{ Product.id }}" form="productForm{{ Product.id }}">
  233.                                         {{ 'カートに入れる'|trans }}
  234.                                     </button>
  235.                                 </div>
  236.                             {% else %}
  237.                                 <div class="ec-productRole__btn">
  238.                                     <button type="button" class="ec-blockBtn--action" disabled="disabled">
  239.                                         {{ 'ただいま品切れ中です。'|trans }}
  240.                                     </button>
  241.                                 </div>
  242.                             {% endif %}
  243.                         </li>
  244.                     {% endfor %}
  245.                 </ul>
  246.             </div>
  247.             <div class="ec-pagerRole">
  248.                 {% include "pager.twig" with {'pages': pagination.paginationData} %}
  249.             </div>
  250.             <div class="productlist_bottom">
  251.                 <div class="productlist_number ec-select">
  252.                     <div>{{ '表示件数'|trans({ '%count%': pagination.totalItemCount })|raw }}</div>
  253.                     {{ form_widget(search_form.disp_number, {'id': '', 'attr': {'class': 'disp-number'}}) }}
  254.                 </div>
  255.                 <div class="ec-searchnavRole__category">
  256.                     <p><a href="{{ url('product_list') }}" class="all_category">宇宙グッズ一覧</a></p>
  257.                     {% if Category is not null %}
  258.                         {% for Path in Category.path %}
  259.                             <p><a href="{{ url('product_list') }}?category_id={{ Path.id }}" class="list_category_{{loop.index}}">{{ Path.name }}</a></p>
  260.                             <script>
  261.                                 $(".category_id_{{ Path.id }}").addClass("is-active").css("display","block");
  262.                                 {% if loop.last %}
  263.                                 $(".category_id_{{ Path.id }}").addClass("is-active_last");
  264.                                 {% endif %}
  265.                             </script>
  266.                         {% endfor %}
  267.                     {% endif %}
  268.                 </div>
  269.             </div>
  270.         {% else %}
  271.             <div class="error_content">
  272.                 <p><img src="{{ asset('assets/img/pages/error_character.png', 'user_data') }}" alt="申し訳ございません。該当する宇宙グッズは見付かりませんでした。" width="112" height="169" /></p>
  273.                 <p>申し訳ございません。</p>
  274.                 <p>お探しの宇宙グッズは見付かりませんでした。</p>
  275.             </div>
  276.             <div class="productlist_bottom error">
  277.                 <div class="ec-searchnavRole__category">
  278.                     <p><a href="{{ url('product_list') }}" class="all_category">宇宙グッズ一覧</a></p>
  279.                 </div>
  280.             </div>
  281.         {% endif %}
  282.     {% endif %}
  283. {% endblock %}