app/template/bynoiezam/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 product_list' %}
  10. {% block stylesheet %}
  11.     <link rel="stylesheet" href="{{ asset('assets/css/game-category-layout.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').html(this);
  62.                     });
  63.                     $('.ec-modal').show()
  64.                     // カートブロックを更新する
  65.                     $.ajax({
  66.                         url: '{{ url('block_cart') }}',
  67.                         type: 'GET',
  68.                         dataType: 'html'
  69.                     }).done(function(html) {
  70.                         $('.ec-headerRole__cart').html(html);
  71.                     });
  72.                 }).fail(function(data) {
  73.                     alert('{{ 'カートへの追加に失敗しました。'|trans }}');
  74.                 }).always(function(data) {
  75.                     // Buttonを有効にする
  76.                     $('.add-cart').prop('disabled', false);
  77.                 });
  78.             });
  79.         });
  80.         $('.ec-modal-wrap').on('click', function(e) {
  81.             // モーダル内の処理は外側にバブリングさせない
  82.             e.stopPropagation();
  83.         });
  84.         $('.ec-modal-overlay, .ec-modal, .ec-modal-close, .ec-inlineBtn--cancel').on('click', function() {
  85.             $('.ec-modal').hide()
  86.         });
  87.         {# ゲーム別レイアウトはプラグイン(NZCategoryLayoutManager42)で処理 #}
  88.     </script>
  89. {% endblock %}
  90. {% block main %}
  91.     {% if search_form.vars.value.category_id.id is defined %}
  92.     {{ include('Block/category'~search_form.vars.value.category_id.id~'.twig', ignore_missing = true) }}
  93.     {% endif %}
  94.     {% if search_form.category_id.vars.errors|length > 0 %}
  95.         <div class="ec-searchnavRole">
  96.             <p class="errormsg text-danger">{{ 'ご指定のカテゴリは存在しません'|trans }}</p>
  97.         </div>
  98.     {% else %}
  99.         <div class="ec-searchnavRole">
  100.             <form name="form1" id="form1" method="get" action="?">
  101.                 {% for item in search_form %}
  102.                     <input type="hidden" id="{{ item.vars.id }}"
  103.                            name="{{ item.vars.full_name }}"
  104.                            {% if item.vars.value is not empty %}value="{{ item.vars.value }}" {% endif %}/>
  105.                 {% endfor %}
  106.             </form>
  107.             <div class="ec-searchnavRole__topicpath">
  108.                 <ol class="ec-topicpath">
  109.                     <li class="ec-topicpath__item"><a href="{{ url('product_list') }}">{{ '全て'|trans }}</a>
  110.                     </li>
  111.                     {% if Category is not null %}
  112.                         {% for Path in Category.path %}
  113.                             <li class="ec-topicpath__divider">|</li>
  114.                             <li class="ec-topicpath__item{% if loop.last %}--active{% endif %}"><a
  115.                                         href="{{ url('product_list') }}?category_id={{ Path.id }}">{{ Path.name }}</a>
  116.                             </li>
  117.                         {% endfor %}
  118.                     {% endif %}
  119.                     {% if search_form.vars.value and search_form.vars.value.name %}
  120.                         <li class="ec-topicpath__divider">|</li>
  121.                         <li class="ec-topicpath__item">{{ '「%name%」の検索結果'|trans({ '%name%': search_form.vars.value.name }) }}</li>
  122.                     {% endif %}
  123.                 </ol>
  124.             </div>
  125.             <div class="ec-searchnavRole__infos">
  126.                 <div class="ec-searchnavRole__counter">
  127.                     {% if pagination.totalItemCount > 0 %}
  128.                         {{ '<span class="ec-font-bold">%count%件</span><span>の商品が見つかりました</span>'|trans({ '%count%': pagination.totalItemCount })|raw }}
  129.                     {% else %}
  130.                         <span>{{ 'お探しの商品は見つかりませんでした'|trans }}</span>
  131.                     {% endif %}
  132.                 </div>
  133.                 {% if pagination.totalItemCount > 0 %}
  134.                     <div class="ec-searchnavRole__actions">
  135.                         <div class="ec-select">
  136.                             {{ form_widget(search_form.disp_number, {'id': '', 'attr': {'class': 'disp-number'}}) }}
  137.                             {{ form_widget(search_form.orderby, {'id': '', 'attr': {'class': 'order-by'}}) }}
  138.                         </div>
  139.                     </div>
  140.                 {% endif %}
  141.             </div>
  142.         </div>
  143.         {% if pagination.totalItemCount > 0 %}
  144.             <div class="ec-shelfRole">
  145.                 <ul class="ec-shelfGrid">
  146.                     {% for Product in pagination %}
  147.                         <li class="ec-shelfGrid__item" 
  148.                             data-product-id="{{ Product.id }}"
  149.                             {% if Product.ProductCategories|length > 0 %}
  150.                                 data-category-ids="{% for pc in Product.ProductCategories %}{{ pc.Category.id }}{% if not loop.last %},{% endif %}{% endfor %}"
  151.                             {% endif %}>
  152.                             <a href="{{ url('product_detail', {'id': Product.id}) }}">
  153.                                 <p class="ec-shelfGrid__item-image">
  154.                                     <img src="{{ asset(Product.main_list_image|no_image_product, 'save_image') }}" alt="{{ Product.name }}" loading="lazy">
  155.                                 </p>
  156.                                 <ul class="ec-shelfRole__tags">
  157.                                     {% for Tag in Product.ProductTag %}
  158.                                     {{ include('@DesignTag42/tag_list.twig', ignore_missing = true) }}
  159.                                         {% if Tag %}
  160.                                             <li class="ec-shelfRole__tag">{{ Tag.Tag }}</li>
  161.                                         {% endif %}
  162.                                     {% endfor %}
  163.                                 </ul>
  164.                                 <p class="ec-shelfGrid__item-name">{{ Product.name }}</p>
  165.                                 {% if Product.description_list %}
  166.                                     <p>{{ Product.description_list|raw|nl2br }}</p>
  167.                                 {% endif %}
  168.                                 <p class="price02-default">
  169.                                     {% if Product.hasProductClass %}
  170.                                         {% if Product.getPrice02Min == Product.getPrice02Max %}
  171.                                             {{ Product.getPrice02IncTaxMin|price }}
  172.                                         {% else %}
  173.                                             {{ Product.getPrice02IncTaxMin|price }} ~ {{ Product.getPrice02IncTaxMax|price }}
  174.                                         {% endif %}
  175.                                     {% else %}
  176.                                         {{ Product.getPrice02IncTaxMin|price }}
  177.                                     {% endif %}
  178.                                 </p>
  179.                             </a>
  180.                         </li>
  181.                     {% endfor %}
  182.                 </ul>
  183.             </div>
  184.             <div class="ec-modal">
  185.                 <div class="ec-modal-overlay">
  186.                     <div class="ec-modal-wrap">
  187.                         <span class="ec-modal-close"><span class="ec-icon"><img src="{{ asset('assets/icon/cross-dark.svg') }}" alt=""/></span></span>
  188.                         <div id="ec-modal-header" class="text-center">{{ 'カートに追加しました。'|trans }}</div>
  189.                         <div class="ec-modal-box">
  190.                             <div class="ec-role">
  191.                                 <span class="ec-inlineBtn--cancel">{{ 'お買い物を続ける'|trans }}</span>
  192.                                 <a href="{{ url('cart') }}" class="ec-inlineBtn--action">{{ 'カートへ進む'|trans }}</a>
  193.                             </div>
  194.                         </div>
  195.                     </div>
  196.                 </div>
  197.             </div>
  198.             <div class="ec-pagerRole">
  199.                 {% include "pager.twig" with {'pages': pagination.paginationData} %}
  200.             </div>
  201.         {% endif %}
  202.     {% endif %}
  203. {% endblock %}