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.     {# headline #}
  88.     <div class="ec-role mt-1">
  89.         <div class="d-flex flex-column flex-md-row justify-content-between">
  90.             <div class="ec-secHeading">
  91.                 <span class="ec-secHeading__en">PRODUCTS</span>
  92.                 <span class="ec-secHeading__line"></span>
  93.                 <span class="ec-secHeading__ja">製品一覧</span>
  94.             </div>
  95.             <div class="d-none d-md-block ec-headerNaviRole__search">
  96.                 {{ render(path('block_search_product')) }}
  97.             </div>
  98.         </div>
  99.         {# tag list #}
  100.         {% set tags = repository('Eccube\\Entity\\Tag').findAll() %}
  101.         {% if tags|length > 0 %}
  102.           <div class="tag-list mt-2">
  103.             <ul class="d-flex gap-1" style="padding-left:0">
  104.               {% for tag in tags %}
  105.                 {% set isActive = app.request.get('tag_id') == tag.id %}
  106.                 <li class="">
  107.                   <a class="btn btn-sm btn-outline-secondary{% if isActive %} btn-primary{% endif %}" href="{{ url('product_list', {'tag_id': tag.id}) }}">{{ tag.name }}</a>
  108.                 </li>
  109.               {% endfor %}
  110.             </ul>
  111.           </div>
  112.         {% endif %}
  113.     </div>
  114.     
  115.     {% if search_form.category_id.vars.errors|length > 0 %}
  116.         <div class="ec-searchnavRole">
  117.             <p class="errormsg text-danger">{{ 'ご指定のカテゴリは存在しません'|trans }}</p>
  118.         </div>
  119.     {% else %}
  120.         <div class="ec-searchnavRole mt-2">
  121.             {% if "now"|date("H") > 11 and "now"|date("H") < 19 %}
  122.             {% else %}
  123.                 <p style="margin-top:20px;">ご注文の受付は<span style="font-weight:bold;color:#ff0000;">11時から19時まで</span>となっており、19時以降の注文の受付はできかねます。<br>
  124.                 翌11時より改めてご注文手続きをしていただきますようよろしくお願いいたします。</p>
  125.             {% endif %}
  126.             <form name="form1" id="form1" method="get" action="?">
  127.                 {% for item in search_form %}
  128.                     <input type="hidden" id="{{ item.vars.id }}"
  129.                            name="{{ item.vars.full_name }}"
  130.                            {% if item.vars.value is not empty %}value="{{ item.vars.value }}" {% endif %}/>
  131.                 {% endfor %}
  132.             </form>
  133.             <div class="ec-searchnavRole__topicpath">
  134.                 <ol class="ec-topicpath">
  135.                     <li class="ec-topicpath__item"><a href="{{ url('product_list') }}">{{ '全て'|trans }}</a>
  136.                     </li>
  137.                     {% if Category is not null %}
  138.                         {% for Path in Category.path %}
  139.                             <li class="ec-topicpath__divider">|</li>
  140.                             <li class="ec-topicpath__item{% if loop.last %}--active{% endif %}"><a
  141.                                         href="{{ url('product_list') }}?category_id={{ Path.id }}">{{ Path.name }}</a>
  142.                             </li>
  143.                         {% endfor %}
  144.                     {% endif %}
  145.                     
  146. {#{% set tagId = app.request.get('tag_id')|force_to_int  %}#}
  147. {#{% if tagId is not null %}#}
  148. {#    <li class="ec-topicpath__divider">|</li>#}
  149. {#    <li class="ec-topicpath__item--active">#}
  150. {#        <a href="{{ url('product_list', {'tag_id': app.request.get('tag_id')}) }}">#}
  151. {#            {{ tags[tagId].name }}#}
  152. {#        </a>#}
  153. {#    </li>#}
  154. {#{% endif %}#}
  155.                     
  156.                     {% if search_form.vars.value and search_form.vars.value.name %}
  157.                         <li class="ec-topicpath__divider">|</li>
  158.                         <li class="ec-topicpath__item">{{ '「%name%」の検索結果'|trans({ '%name%': search_form.vars.value.name }) }}</li>
  159.                     {% endif %}
  160.                 </ol>
  161.             </div>
  162.             <div class="ec-searchnavRole__infos">
  163.                 <div class="ec-searchnavRole__counter">
  164.                     {% if pagination.totalItemCount > 0 %}
  165.                         {{ '<span class="ec-font-bold">%count%件</span><span>の商品が見つかりました</span>'|trans({ '%count%': pagination.totalItemCount })|raw }}
  166.                     {% else %}
  167.                         <span>{{ 'お探しの商品は見つかりませんでした'|trans }}</span>
  168.                     {% endif %}
  169.                 </div>
  170.                 {#{% if pagination.totalItemCount > 0 %}#}
  171.                 {#    <div class="ec-searchnavRole__actions">#}
  172.                 {#        <div class="ec-select">#}
  173.                 {#            {{ form_widget(search_form.disp_number, {'id': '', 'attr': {'class': 'disp-number'}}) }}#}
  174.                 {#            {{ form_widget(search_form.orderby, {'id': '', 'attr': {'class': 'order-by'}}) }}#}
  175.                 {#        </div>#}
  176.                 {#    </div>#}
  177.                 {#{% endif %}#}
  178.             </div>
  179.         </div>
  180.         
  181.         {% if pagination.totalItemCount > 0 %}
  182.             <div class="ec-role">
  183.                 <div class="ec-shelfRole ec-newItemRole pt-2">
  184.                     <ul class="ec-shelfGrid">
  185.                     {% for Product in pagination %}
  186.                         <li class="ec-shelfGrid__item">
  187.                             <a href="{{ url('product_detail', {'id': Product.id}) }}">
  188.                                 <p class="ec-shelfGrid__item-image">
  189.                                     <img src="{{ asset(Product.main_list_image|no_image_product, 'save_image') }}" alt="{{ Product.name }}" {% if loop.index > 5 %} loading="lazy"{% endif %}>
  190.                                 </p>
  191.                                 <p class="ec-newItemRole__listItemTitle">{{ Product.name }}</p>
  192.                                 {% if Product.description_list %}
  193.                                     <p>{{ Product.description_list|raw|nl2br }}</p>
  194.                                 {% endif %}
  195.                                 <p class="ec-newItemRole__listItemPrice">
  196.                                     {% if is_granted('ROLE_USER') %}
  197.                                         {% if Product.hasProductClass %}
  198.                                             {% if Product.getPrice02Min == Product.getPrice02Max %}
  199.                                                 {% set getPrice02NoTaxMin = ceil(Product.getPrice02IncTaxMin / 1.1) %}
  200.                                                 {{ Product.getPrice02IncTaxMin|price }}(税込)/
  201.                                                 {{ getPrice02NoTaxMin|price }}(税抜)
  202.                                             {% else %}
  203.                                                 {% set getPrice02NoTaxMin = ceil(Product.getPrice02IncTaxMin / 1.1) %}
  204.                                                 {% set getPrice02NoTaxMax = ceil(Product.getPrice02IncTaxMax / 1.1) %}
  205.                                                 {{ Product.getPrice02IncTaxMin|price }} ~ {{ Product.getPrice02IncTaxMax|price }}(税込)/<br>
  206.                                                 {{ getPrice02NoTaxMin|price }} ~ {{ getPrice02NoTaxMax|price }}(税抜)
  207.                                             {% endif %}
  208.                                         {% else %}
  209.                                             {% set getPrice02NoTaxMin = ceil(Product.getPrice02IncTaxMin / 1.1) %}
  210.                                             {{ Product.getPrice02IncTaxMin|price }}(税込)/
  211.                                             {{ getPrice02NoTaxMin|price }}(税抜)
  212.                                         {% endif %}
  213.                                     {% else %}
  214.                                         価格:お問い合わせください
  215.                                     {% endif %}
  216.                                 </p>
  217.                                 {% for productClass in Product.ProductClasses %}
  218.                                     <p class="ec-newItemRole__listItemPrice">在庫数:{{ productClass.getSaleLimit() }}</p>
  219.                                 {% endfor %}
  220.                             </a>
  221.                             {% if is_granted('ROLE_USER') %}
  222.                                 {% if Product.stock_find %}
  223.                                     {% set form = forms[Product.id] %}
  224.                                     <form name="form{{ Product.id }}" id="productForm{{ Product.id }}" action="{{ url('product_add_cart', {id:Product.id}) }}" method="post">
  225.                                         <div class="ec-productRole__actions">
  226.                                             {% if form.classcategory_id1 is defined %}
  227.                                                 <div class="ec-select">
  228.                                                     {{ form_widget(form.classcategory_id1) }}
  229.                                                     {{ form_errors(form.classcategory_id1) }}
  230.                                                 </div>
  231.                                                 {% if form.classcategory_id2 is defined %}
  232.                                                     <div class="ec-select">
  233.                                                         {{ form_widget(form.classcategory_id2) }}
  234.                                                         {{ form_errors(form.classcategory_id2) }}
  235.                                                     </div>
  236.                                                 {% endif %}
  237.                                             {% endif %}
  238.                                             <div class="ec-numberInput"><span>{{ '数量'|trans }}</span>
  239.                                                 {{ form_widget(form.quantity, {'attr': {'class': 'quantity'}}) }}
  240.                                                 {{ form_errors(form.quantity) }}
  241.                                             </div>
  242.                                         </div>
  243.                                         {{ form_rest(form) }}
  244.                                     </form>
  245.                                     <div class="ec-productRole__btn">
  246.                                         <button type="submit" class="ec-blockBtn--action add-cart" data-cartid="{{ Product.id }}" form="productForm{{ Product.id }}">
  247.                                             {{ 'カートに入れる'|trans }}
  248.                                         </button>
  249.                                     </div>
  250.                                 {% else %}
  251.                                     <div class="ec-productRole__btn">
  252.                                         <button type="button" class="ec-blockBtn--action" disabled="disabled">
  253.                                             {{ 'ただいま品切れ中です。'|trans }}
  254.                                         </button>
  255.                                     </div>
  256.                                 {% endif %}
  257.                             {% endif %}
  258.                         </li>
  259.                     {% endfor %}
  260.                 </ul>
  261.                 </div>  
  262.             </div>
  263.             <div class="ec-modal">
  264.                 <div class="ec-modal-overlay">
  265.                     <div class="ec-modal-wrap">
  266.                         <span class="ec-modal-close"><span class="ec-icon"><img src="{{ asset('assets/icon/cross-dark.svg') }}" alt=""/></span></span>
  267.                         <div id="ec-modal-header" class="text-center">{{ 'カートに追加しました。'|trans }}</div>
  268.                         <div class="ec-modal-box">
  269.                             <div class="ec-role">
  270.                                 <span class="ec-inlineBtn--cancel">{{ 'お買い物を続ける'|trans }}</span>
  271.                                 <a href="{{ url('cart') }}" class="ec-inlineBtn--action">{{ 'カートへ進む'|trans }}</a>
  272.                             </div>
  273.                         </div>
  274.                     </div>
  275.                 </div>
  276.             </div>
  277.             <div class="ec-pagerRole">
  278.                 {% include "pager.twig" with {'pages': pagination.paginationData} %}
  279.             </div>
  280.         {% endif %}
  281.         
  282.         <div class="ec-role">
  283.             {# search box #}
  284.             <div class="d-md-none ec-headerNaviRole__search">
  285.                 {{ render(path('block_search_product')) }}
  286.             </div>
  287.         </div>
  288.     {% endif %}
  289. {% endblock %}