app/template/originalTemplate/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. {% set category_id = '0' %}
  11. {% if app.request.query.get('category_id') != "" %}
  12.     {% set category_id = app.request.query.get('category_id') %}
  13. {% endif %}
  14. {% block stylesheet %}
  15.     <style>
  16.         .categoryImgArea
  17.         {
  18.             background-image: url(/html/user_data/assets/img/category/category_bg_id-{{ category_id }}.jpg);
  19.             background-size:cover;
  20.             background-position: center;
  21.             height: 375px;
  22.             display: flex;
  23.             /*flex-direction: column;*/
  24.             justify-content: center;
  25.             align-items: center;
  26.         }
  27.         .categoryImgArea img
  28.         {
  29.             max-width: 80vw;
  30.         }
  31.     </style>
  32. {% endblock %}
  33. {% block javascript %}
  34.     <script>
  35.         eccube.productsClassCategories = {
  36.             {% for Product in pagination %}
  37.             "{{ Product.id|escape('js') }}": {{ class_categories_as_json(Product)|raw }}{% if loop.last == false %}, {% endif %}
  38.             {% endfor %}
  39.         };
  40.         $(function() {
  41.             // 表示件数を変更
  42.             $('.disp-number').change(function() {
  43.                 var dispNumber = $(this).val();
  44.                 $('#disp_number').val(dispNumber);
  45.                 $('#pageno').val(1);
  46.                 $("#form1").submit();
  47.             });
  48.             // 並び順を変更
  49.             $('.order-by').change(function() {
  50.                 var orderBy = $(this).val();
  51.                 $('#orderby').val(orderBy);
  52.                 $('#pageno').val(1);
  53.                 $("#form1").submit();
  54.             });
  55.             $('.add-cart').on('click', function(e) {
  56.                 var $form = $(this).parents('li').find('form');
  57.                 // 個数フォームのチェック
  58.                 var $quantity = $form.parent().find('.quantity');
  59.                 if ($quantity.val() < 1) {
  60.                     $quantity[0].setCustomValidity('{{ '1以上で入力してください。'|trans }}');
  61.                     setTimeout(function() {
  62.                         loadingOverlay('hide');
  63.                     }, 100);
  64.                     return true;
  65.                 } else {
  66.                     $quantity[0].setCustomValidity('');
  67.                 }
  68.                 e.preventDefault();
  69.                 $.ajax({
  70.                     url: $form.attr('action'),
  71.                     type: $form.attr('method'),
  72.                     data: $form.serialize(),
  73.                     dataType: 'json',
  74.                     beforeSend: function(xhr, settings) {
  75.                         // Buttonを無効にする
  76.                         $('.add-cart').prop('disabled', true);
  77.                     }
  78.                 }).done(function(data) {
  79.                     // レスポンス内のメッセージをalertで表示
  80.                     $.each(data.messages, function() {
  81.                         $('#ec-modal-header').html(this);
  82.                     });
  83.                     $('.ec-modal').show()
  84.                     // カートブロックを更新する
  85.                     $.ajax({
  86.                         url: '{{ url('block_cart') }}',
  87.                         type: 'GET',
  88.                         dataType: 'html'
  89.                     }).done(function(html) {
  90.                         $('.ec-headerRole__cart').html(html);
  91.                     });
  92.                 }).fail(function(data) {
  93.                     alert('{{ 'カートへの追加に失敗しました。'|trans }}');
  94.                 }).always(function(data) {
  95.                     // Buttonを有効にする
  96.                     $('.add-cart').prop('disabled', false);
  97.                 });
  98.             });
  99.         });
  100.         $('.ec-modal-overlay, .ec-modal .ec-inlineBtn--cancel').on('click', function() {
  101.             $('.ec-modal').hide()
  102.         });
  103.     </script>
  104. {% endblock %}
  105. {% block main %}
  106.     {% set category_name = 'すべての商品' %}
  107.     {% if Category is not null %}
  108.         {% set category_name = Category.name %}
  109.     {% endif %}
  110.     <div class="categoryImgArea">
  111.     {# <img src="/html/user_data/assets/img/category/category_banner_id-{{ category_id }}.jpg" alt="カテゴリ画像-{{ category_id }}"> #}
  112.     <h2 class="page_title">{{ category_name }}</h2>
  113.     </div>
  114.     {% if search_form.category_id.vars.errors|length > 0 %}
  115.         <div class="ec-searchnavRole">
  116.             <p class="errormsg text-danger">{{ 'ご指定のカテゴリは存在しません'|trans }}</p>
  117.         </div>
  118.     {% else %}
  119.         <div class="ec-searchnavRole">
  120.             <form name="form1" id="form1" method="get" action="?">
  121.                 {% for item in search_form %}
  122.                     <input type="hidden" id="{{ item.vars.id }}"
  123.                            name="{{ item.vars.full_name }}"
  124.                            {% if item.vars.value is not empty %}value="{{ item.vars.value }}" {% endif %}/>
  125.                 {% endfor %}
  126.             </form>
  127.             <div class="ec-searchnavRole__topicpath">
  128.                 <ol class="ec-topicpath">
  129.                     <li class="ec-topicpath__item"><a href="{{ url('product_list') }}">{{ '全て'|trans }}</a>
  130.                     </li>
  131.                     {% if Category is not null %}
  132.                         {% for Path in Category.path %}
  133.                             <li class="ec-topicpath__divider">|</li>
  134.                             <li class="ec-topicpath__item{% if loop.last %}--active{% endif %}"><a
  135.                                         href="{{ url('product_list') }}?category_id={{ Path.id }}">{{ Path.name }}</a>
  136.                             </li>
  137.                         {% endfor %}
  138.                     {% endif %}
  139.                     {% if search_form.vars.value and search_form.vars.value.name %}
  140.                         <li class="ec-topicpath__divider">|</li>
  141.                         <li class="ec-topicpath__item">{{ '「%name%」の検索結果'|trans({ '%name%': search_form.vars.value.name }) }}</li>
  142.                     {% endif %}
  143.                 </ol>
  144.             </div>
  145.             <div class="ec-searchnavRole__infos">
  146.                 <div class="ec-searchnavRole__counter">
  147.                     {% if pagination.totalItemCount > 0 %}
  148.                         {{ '<span class="ec-font-bold">%count%件</span><span>の商品が見つかりました</span>'|trans({ '%count%': pagination.totalItemCount })|raw }}
  149.                     {% else %}
  150.                         <span>{{ 'お探しの商品は見つかりませんでした'|trans }}</span>
  151.                     {% endif %}
  152.                 </div>
  153.                 {% if pagination.totalItemCount > 0 %}
  154.                     <div class="ec-searchnavRole__actions">
  155.                         <div class="ec-select">
  156.                             {{ form_widget(disp_number_form, {'id': '', 'attr': {'class': 'disp-number'}}) }}
  157.                             {{ form_widget(order_by_form, {'id': '', 'attr': {'class': 'order-by'}}) }}
  158.                         </div>
  159.                     </div>
  160.                 {% endif %}
  161.             </div>
  162.         </div>
  163.         {% if pagination.totalItemCount > 0 %}
  164.             <div class="ec-shelfRole">
  165.                 <ul class="ec-shelfGrid">
  166.                     {% for Product in pagination %}
  167.                         <li class="ec-shelfGrid__item">
  168.                             <a href="{{ url('product_detail', {'id': Product.id}) }}">
  169.                                 <div class="ec-shelfGrid__item-image__wrapper">
  170.                                     <p class="ec-shelfGrid__item-image">
  171.                                         <img src="{{ asset(Product.main_list_image|no_image_product, 'save_image') }}">
  172.                                     </p>
  173.                                 </div>
  174.                                 <p class="product_name">{{ Product.name }}</p>
  175.                                 {% if Product.description_list %}
  176.                                     <p>{{ Product.description_list|raw|nl2br }}</p>
  177.                                 {% endif %}
  178.                                 <p class="price02-default">
  179.                                     {% if Product.hasProductClass %}
  180.                                         {% if Product.getPrice02Min == Product.getPrice02Max %}
  181.                                             {{ Product.getPrice02IncTaxMin|price }}(税込)
  182.                                         {% else %}
  183.                                             {{ Product.getPrice02IncTaxMin|price }} ~ {{ Product.getPrice02IncTaxMax|price }}(税込)
  184.                                         {% endif %}
  185.                                     {% else %}
  186.                                         {{ Product.getPrice02IncTaxMin|price }}(税込)
  187.                                     {% endif %}
  188.                                 </p>
  189.                             </a>
  190.                             {# {% if Product.stock_find %}
  191.                                 {% set form = forms[Product.id] %}
  192.                                 <form name="form{{ Product.id }}" id="productForm{{ Product.id }}" action="{{ url('product_add_cart', {id:Product.id}) }}" method="post">
  193.                                     <div class="ec-productRole__actions">
  194.                                         {% if form.classcategory_id1 is defined %}
  195.                                             <div class="ec-select">
  196.                                                 {{ form_widget(form.classcategory_id1) }}
  197.                                                 {{ form_errors(form.classcategory_id1) }}
  198.                                             </div>
  199.                                             {% if form.classcategory_id2 is defined %}
  200.                                                 <div class="ec-select">
  201.                                                     {{ form_widget(form.classcategory_id2) }}
  202.                                                     {{ form_errors(form.classcategory_id2) }}
  203.                                                 </div>
  204.                                             {% endif %}
  205.                                         {% endif %}
  206.                                         <div class="ec-numberInput"><span>{{ '数量'|trans }}</span>
  207.                                             {{ form_widget(form.quantity, {'attr': {'class': 'quantity'}}) }}
  208.                                             {{ form_errors(form.quantity) }}
  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" data-cartid="{{ Product.id }}" form="productForm{{ Product.id }}">
  215.                                         {{ 'カートに入れる'|trans }}
  216.                                     </button>
  217.                                 </div>
  218.                             {% else %}
  219.                                 <div class="ec-productRole__btn">
  220.                                     <button type="button" class="ec-blockBtn--action" disabled="disabled">
  221.                                         {{ 'ただいま品切れ中です。'|trans }}
  222.                                     </button>
  223.                                 </div>
  224.                             {% endif %} #}
  225.                         </li>
  226.                     {% endfor %}
  227.                 </ul>
  228.             </div>
  229.             <div class="ec-modal">
  230.                 <div class="ec-modal-overlay">
  231.                     <div class="ec-modal-wrap">
  232.                         <span class="ec-modal-close"><span class="ec-icon"><img src="{{ asset('assets/icon/cross-dark.svg') }}" alt=""/></span></span>
  233.                         <div id="ec-modal-header" class="text-center">{{ 'カートに追加しました。'|trans }}</div>
  234.                         <div class="ec-modal-box">
  235.                             <div class="ec-role">
  236.                                 <span class="ec-inlineBtn--cancel">{{ 'お買い物を続ける'|trans }}</span>
  237.                                 <a href="{{ url('cart') }}" class="ec-inlineBtn--action">{{ 'カートへ進む'|trans }}</a>
  238.                             </div>
  239.                         </div>
  240.                     </div>
  241.                 </div>
  242.             </div>
  243.             <div class="ec-pagerRole">
  244.                 {% include "pager.twig" with {'pages': pagination.paginationData} %}
  245.             </div>
  246.         {% endif %}
  247.     {% endif %}
  248. {% endblock %}