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