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. <style>
  12. .c_sale {
  13.     position: absolute;
  14.     top: 0;
  15.     background-color: red;
  16.     padding: 4px 8px;
  17.     color: #fff;
  18.     font-size: 12px;
  19. }
  20. </style>
  21. {% endblock %}
  22. {% block javascript %}
  23.      <script>
  24.         eccube.productsClassCategories = {
  25.             {% for Product in pagination %}
  26.             "{{ Product.id|escape('js') }}": {{ class_categories_as_json(Product)|raw }}{% if loop.last == false %}, {% endif %}
  27.             {% endfor %}
  28.         };
  29.                                     
  30.         $(function() {
  31.             // 表示件数を変更
  32.             $('.disp-number').change(function() {
  33.                 var dispNumber = $(this).val();
  34.                 $('#disp_number').val(dispNumber);
  35.                 $('#pageno').val(1);
  36.                 $("#form1").submit();
  37.             });
  38.             // 並び順を変更
  39.             $('.order-by').change(function() {
  40.                 var orderBy = $(this).val();
  41.                 $('#pageno').val(1);
  42.                 $('#orderby').val(orderBy);
  43.                 $("#form1").submit();
  44.             });
  45.             $('.add-cart').on('click', function(e) {
  46.                 var $form = $(this).parents('li').find('form');
  47.                 // 個数フォームのチェック
  48.                 var $quantity = $form.parent().find('.quantity');
  49.                 if ($quantity.val() < 1) {
  50.                     $quantity[0].setCustomValidity('{{ '1以上で入力してください。'|trans }}');
  51.                     setTimeout(function() {
  52.                         loadingOverlay('hide');
  53.                     }, 100);
  54.                     return true;
  55.                 } else {
  56.                     $quantity[0].setCustomValidity('');
  57.                 }
  58.                 e.preventDefault();
  59.                 $.ajax({
  60.                     url: $form.attr('action'),
  61.                     type: $form.attr('method'),
  62.                     data: $form.serialize(),
  63.                     dataType: 'json',
  64.                     beforeSend: function(xhr, settings) {
  65.                         // Buttonを無効にする
  66.                         $('.add-cart').prop('disabled', true);
  67.                     }
  68.                 }).done(function(data) {
  69.                     // レスポンス内のメッセージをalertで表示
  70.                     $.each(data.messages, function() {
  71.                         $('#ec-modal-header').text(this);
  72.                     });
  73.                     $('.ec-modal').show()
  74.                     // カートブロックを更新する
  75.                     $.ajax({
  76.                         url: '{{ url('block_cart') }}',
  77.                         type: 'GET',
  78.                         dataType: 'html'
  79.                     }).done(function(html) {
  80.                         $('.ec-headerRole__cart').html(html);
  81.                     });
  82.                 }).fail(function(data) {
  83.                     alert('{{ 'カートへの追加に失敗しました。'|trans }}');
  84.                 }).always(function(data) {
  85.                     // Buttonを有効にする
  86.                     $('.add-cart').prop('disabled', false);
  87.                 });
  88.             });
  89.         });
  90.                                     
  91.         $('.ec-modal-wrap').on('click', function(e) {
  92.             // モーダル内の処理は外側にバブリングさせない
  93.             e.stopPropagation();
  94.         });
  95.         $('.ec-modal-overlay, .ec-modal, .ec-modal-close, .ec-inlineBtn--cancel').on('click', function() {
  96.             $('.ec-modal').hide()
  97.         });
  98.                                             
  99.                                            
  100.     </script>
  101. {% endblock %}
  102. {% block main %}
  103.     <div class="ec-productRole">
  104.         <ol class="breadcrumb" itemscope itemtype="https://schema.org/BreadcrumbList">
  105.             <li itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem">
  106.                 <a itemprop="item" href="/">
  107.                     <span itemprop="name">TOP</span>
  108.                 </a>
  109.                 <meta itemprop="position" content="1"/>
  110.             </li>
  111.             {% if Category is not null %}
  112.                 {% for Path in Category.path %}
  113.                     <li itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem">
  114.                         <a itemprop="item" href="{{ url('product_list') }}?category_id={{ Path.id }}">
  115.                             <span itemprop="name">{{ Path.name }}</span>
  116.                         </a>
  117.                         <meta itemprop="position" content="2"/>
  118.                     </li>
  119.                 {% endfor %}
  120.             {% endif %}
  121.         </ol>
  122.     </div>
  123.     {% if search_form.category_id.vars.errors|length > 0 %}
  124.         <div class="ec-searchnavRole">
  125.             <p class="errormsg text-danger">{{ 'ご指定のカテゴリは存在しません'|trans }}</p>
  126.         </div>
  127.     {% else %}
  128.         <div class="ec-searchnavRole">
  129.             <form name="form1" id="form1" method="get" action="?">
  130.                 {% for item in search_form %}
  131.                     <input type="hidden" id="{{ item.vars.id }}" name="{{ item.vars.full_name }}" {% if item.vars.value is not empty %} value="{{ item.vars.value }}" {% endif %}/>
  132.                 {% endfor %}
  133.             </form>
  134.             <div
  135.                 class="ec-searchnavRole__topicpath gnavi__list_sp">
  136.                 {# カテゴリー一覧 #}
  137.                 {% set all_categories = [] %}
  138.                 {# 親カテゴリーを追加 #}
  139.                 {% if Category is not null and Category.path is not null %}
  140.                     {% for Path in Category.path %}
  141.                         {% set category_item = { 'id': Path.id, 'name': Path.name } %}
  142.                         {% if category_item not in all_categories %}
  143.                             {% set all_categories = all_categories | merge([category_item]) %}
  144.                         {% endif %}
  145.                     {% endfor %}
  146.                 {% endif %}
  147.                 {# 子カテゴリーを追加 #}
  148.                 {% if Category is not null %}
  149.                     {% set cate_childs = Category.getDescendants %}
  150.                     {% for cate in cate_childs %}
  151.                         {% set category_item = { 'id': cate.id, 'name': cate.name } %}
  152.                         {% if category_item not in all_categories %}
  153.                             {% set all_categories = all_categories | merge([category_item]) %}
  154.                         {% endif %}
  155.                     {% endfor %}
  156.                 {% endif %}
  157.                 {# カテゴリーリストSP #}
  158.                 <div class="ec-itemNav__listSp">
  159.                     <div class="ec-itemNav gnavi__list_sp">
  160.                         <span class="ec-itemNav-dropdown js-dropdown">
  161.                             選択してください<span class="dli-chevron-down"></span>
  162.                         </span>
  163.                         {# 全てのカテゴリーを表示 #}
  164.                         {#
  165.                         <div class="dropdown__lists_sp js-dropdown-contents">
  166.                             <ul class="ec-itemNav__nav">
  167.                                 {% for loop_index, category in all_categories %}
  168.                                     {% if loop_index == 0 %}
  169.                                         <li class="ec-topicpath__item dropdown__list_sp{% if category.id == app.request.query.get('category_id') %} ec-topicpath__item--active{% endif %}">
  170.                                             <a href="/products/list?category_id={{ category.id }}">全て</a>
  171.                                         </li>
  172.                                     {% else %}
  173.                                         <li class="ec-topicpath__item dropdown__list_sp{% if category.id == app.request.query.get('category_id') %} ec-topicpath__item--active{% endif %}">
  174.                                             <a href="/products/list?category_id={{ category.id }}">{{ category.name }}</a>
  175.                                         </li>
  176.                                     {% endif %}
  177.                                 {% endfor %}
  178.                             </ul>
  179.                         </div>
  180.                         #}
  181.                     </div>
  182.                 </div>
  183.                 {# カテゴリーリストPC #}
  184.                 <ul class="ec-topicpath ec-topicpath__listPc">
  185.                     {% for loop_index, category in all_categories %}
  186.                         {% if loop_index == 0 %}
  187.                             <li class="ec-topicpath__item dropdown__list_sp{% if category.id == app.request.query.get('category_id') %} ec-topicpath__item--active{% endif %}">
  188.                                 <a href="/products/list?category_id={{ category.id }}">全て</a>
  189.                             </li>
  190.                         {% else %}
  191.                             <li class="ec-topicpath__item dropdown__list_sp{% if category.id == app.request.query.get('category_id') %} ec-topicpath__item--active{% endif %}">
  192.                                 <a href="/products/list?category_id={{ category.id }}">{{ category.name }}</a>
  193.                             </li>
  194.                         {% endif %}
  195.                     {% endfor %}
  196.                 </ul>
  197.             </div>
  198.             <div class="ec-searchnavRole__infos">
  199.                 <div class="ec-searchnavRole__counter">
  200.                     {% if pagination.totalItemCount > 0 %}
  201.                         {{ '<span class="ec-font-bold">%count%件</span><span>の商品が見つかりました</span>'|trans({ '%count%': pagination.totalItemCount })|raw }}
  202.                     {% else %}
  203.                         <span>{{ 'お探しの商品は見つかりませんでした'|trans }}</span>
  204.                     {% endif %}
  205.                 </div>
  206.                 {% if pagination.totalItemCount > 0 %}
  207.                     <div class="ec-searchnavRole__actions">
  208.                         <div
  209.                             class="ec-select">
  210.                             {# {{ form_widget(search_form.disp_number, {'id': '', 'attr': {'class': 'disp-number'}}) }}#}
  211.                             {{ form_widget(search_form.orderby, {'id': '', 'attr': {'class': 'order-by'}}) }}
  212.                         </div>
  213.                     </div>
  214.                 {% endif %}
  215.             </div>
  216.         </div>
  217.         {% if pagination.totalItemCount > 0 %}
  218.                 <div class="ec-pagerRole">
  219.                 {% include "pager.twig" with {'pages': pagination.paginationData} %}
  220.             </div>
  221.             <div class="ec-shelfRole">
  222.                 <ul class="ec-shelfGrid">
  223.                     {% for Product in pagination %}
  224.                         <li class="ec-shelfGrid__item">
  225.                             <a href="{{ url('product_detail', {'id': Product.id}) }}">
  226.                                 <p class="ec-shelfGrid__item-image">
  227.                                     <img src="{{ asset(Product.main_list_image|no_image_product, 'save_image') }}" alt="{{ Product.name }}" {% if loop.index > 5 %} loading="lazy" {% endif %}>
  228.                                 </p>
  229.                                 <div class="ec-shelfGrid__item_border"></div>
  230.                                 <p class="ec-shelfGrid__item-title">{{ Product.name }}</p>
  231.                                 {% if Product.description_list %}
  232.                                     <p>{{ Product.description_list|raw|nl2br }}</p>
  233.                                 {% endif %}
  234.                                 <p class="price02-default">
  235.                                     {% if Product.hasProductClass %}
  236.                                         {% if Product.getPrice02Min == Product.getPrice02Max %}
  237.                                             {{ Product.getPrice02IncTaxMin|price }}
  238.                                         {% else %}
  239.                                             {{ Product.getPrice02IncTaxMin|price }}
  240.                                             ~
  241.                                             {{ Product.getPrice02IncTaxMax|price }}
  242.                                         {% endif %}
  243.                                     {% else %}
  244.                                         {{ Product.getPrice02IncTaxMin|price }}
  245.                                     {% endif %}
  246.                                     {% if not Product.stock_find %}<span>SOLD OUT</span>{% endif %}
  247.                                 </p>
  248.                                 {% if Product.getPrice01Min is not null and Product.getPrice01IncTaxMin == Product.getPrice01IncTaxMax %}
  249.                                     <div class="c_sale"><span class="price01-default">SALE</span></div>
  250.                                 {% endif %}
  251.                             </a>
  252.  {{ include('Block/product_list_favorite_block.twig') }}
  253.                             {#{% if Product.stock_find %}
  254.                                                                                                                                                                                                                                                                                                 {% set form = forms[Product.id] %}
  255.                                                                                                                                                                                                                                                                                                 <form name="form{{ Product.id }}" id="productForm{{ Product.id }}" action="{{ url('product_add_cart', {id:Product.id}) }}" method="post">
  256.                                                                                                                                                                                                                                                                                                     <div class="ec-productRole__actions">
  257.                                                                                                                                                                                                                                                                                                         {% if form.classcategory_id1 is defined %}
  258.                                                                                                                                                                                                                                                                                                             <div class="ec-select">
  259.                                                                                                                                                                                                                                                                                                                 {{ form_widget(form.classcategory_id1) }}
  260.                                                                                                                                                                                                                                                                                                                 {{ form_errors(form.classcategory_id1) }}
  261.                                                                                                                                                                                                                                                                                                             </div>
  262.                                                                                                                                                                                                                                                                                                             {% if form.classcategory_id2 is defined %}
  263.                                                                                                                                                                                                                                                                                                                 <div class="ec-select">
  264.                                                                                                                                                                                                                                                                                                                     {{ form_widget(form.classcategory_id2) }}
  265.                                                                                                                                                                                                                                                                                                                     {{ form_errors(form.classcategory_id2) }}
  266.                                                                                                                                                                                                                                                                                                                 </div>
  267.                                                                                                                                                                                                                                                                                                             {% endif %}
  268.                                                                                                                                                                                                                                                                                                         {% endif %}
  269.                                                                                                                                                                                                                                                                                                         <div class="ec-numberInput"><span>{{ '数量'|trans }}</span>
  270.                                                                                                                                                                                                                                                                                                             {{ form_widget(form.quantity, {'attr': {'class': 'quantity'}}) }}
  271.                                                                                                                                                                                                                                                                                                             {{ form_errors(form.quantity) }}
  272.                                                                                                                                                                                                                                                                                                         </div>
  273.                                                                                                                                                                                                                                                                                                     </div>
  274.                                                                                                                                                                                                                                                                                                     {{ form_rest(form) }}
  275.                                                                                                                                                                                                                                                                                                 </form>
  276.                                                                                                                                                                                                                                                                                                 <div class="ec-productRole__btn">
  277.                                                                                                                                                                                                                                                                                                     <button type="submit" class="ec-blockBtn--action add-cart" data-cartid="{{ Product.id }}" form="productForm{{ Product.id }}">
  278.                                                                                                                                                                                                                                                                                                         {{ 'カートに入れる'|trans }}
  279.                                                                                                                                                                                                                                                                                                     </button>
  280.                                                                                                                                                                                                                                                                                                 </div>
  281.                                                                                                                                                                                                                                                                                             {% else %}
  282.                                                                                                                                                                                                                                                                                                 <div class="ec-productRole__btn">
  283.                                                                                                                                                                                                                                                                                                     <button type="button" class="ec-blockBtn--action" disabled="disabled">
  284.                                                                                                                                                                                                                                                                                                         {{ 'ただいま品切れ中です。'|trans }}
  285.                                                                                                                                                                                                                                                                                                     </button>
  286.                                                                                                                                                                                                                                                                                                 </div>
  287.                                                                                                                                                                                                                                                                                             {% endif %}#}
  288.                         </li>
  289.                     {% endfor %}
  290.                 </ul>
  291.                             <div class="ec-pagerRole">
  292.                 {% include "pager.twig" with {'pages': pagination.paginationData} %}
  293.             </div>
  294.             </div>
  295.             <div class="ec-modal">
  296.                 <div class="ec-modal-overlay">
  297.                     <div class="ec-modal-wrap">
  298.                         <span class="ec-modal-close">
  299.                             <span class="ec-icon"><img src="{{ asset('assets/icon/cross-dark.svg') }}" alt=""/></span>
  300.                         </span>
  301.                         <div id="ec-modal-header" class="text-center">{{ 'カートに追加しました。'|trans }}</div>
  302.                         <div class="ec-modal-box">
  303.                             <div class="ec-role">
  304.                                 <span class="ec-inlineBtn--cancel">{{ 'お買い物を続ける'|trans }}</span>
  305.                                 <a href="{{ url('cart') }}" class="ec-inlineBtn--action">{{ 'カートへ進む'|trans }}</a>
  306.                             </div>
  307.                         </div>
  308.                     </div>
  309.                 </div>
  310.             </div>
  311.         {% endif %}
  312.     {% endif %}
  313. {% endblock %}