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').html(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. <div class="ec-searchnavRole">
  88. <div id="cate_list">
  89. <h1 class="cate_h1">{{ subtitle }}</h1>
  90. <ul class="cate_list">
  91.                     <li class="ec-topicpath__item"><a href="{{ url('product_list') }}">{{ '全て'|trans }}</a>
  92.                     </li>
  93.                     {% if Category is not null %}
  94.                         {% for Path in Category.path %}
  95.                             <li class="ec-topicpath__divider">|</li>
  96.                             <li class="ec-topicpath__item{% if loop.last %}--active{% endif %}"><a
  97.                                         href="{{ url('product_list') }}?category_id={{ Path.id }}">{{ Path.name }}</a>
  98.                             </li>
  99.                         {% endfor %}
  100.                     {% endif %}
  101.                     {% if search_form.vars.value and search_form.vars.value.name %}
  102.                         <li class="ec-topicpath__divider">|</li>
  103.                         <li class="ec-topicpath__item">{{ '「%name%」の検索結果'|trans({ '%name%': search_form.vars.value.name }) }}</li>
  104.                     {% endif %}
  105. </ul>
  106. </div>
  107. </div>
  108. {% if Category%}
  109.        
  110. <div class="ec-searchnavRole">
  111. <div class="category wrap">
  112.        
  113. <div class="pic">
  114.     {% set num = Category.id|sprintf_tow %}
  115.     {% set imgs = "assets/images/cat" ~ num ~ ".png" %}
  116.     
  117.     {%if Category.category_image%}
  118.     <img src="{{ asset(Category.category_image|no_image_product, 'save_image') }}" alt="{{ Category.name }}">
  119.     {%else%}
  120.     <img src="{{ asset(imgs, 'user_data') }}" alt="">
  121.     {%endif%}
  122. </div>    
  123. {% if Category and Category.free_area %}
  124.     <div class="read">
  125.         {{ include(template_from_string(Category. free_area))|nl2br }}
  126.     </div>
  127. {% endif %}
  128. </div>
  129. </div>
  130. {% endif %}
  131.     {% if search_form.category_id.vars.errors|length > 0 %}
  132.         <div class="ec-searchnavRole">
  133.             <p class="errormsg text-danger" style="padding: 5em 0;">{{ 'ご指定のカテゴリは存在しません'|trans }}</p>
  134.         </div>
  135.     {% else %}
  136.         <div class="ec-searchnavRole">
  137.             <form name="form1" id="form1" method="get" action="?">
  138.                 {% for item in search_form %}
  139.                     <input type="hidden" id="{{ item.vars.id }}"
  140.                            name="{{ item.vars.full_name }}"
  141.                            {% if item.vars.value is not empty %}value="{{ item.vars.value }}" {% endif %}/>
  142.                 {% endfor %}
  143.             </form>
  144.             <div class="ec-searchnavRole__infos">
  145.                 <div class="ec-searchnavRole__counter">
  146.                     {% if pagination.totalItemCount > 0 %}
  147.                         {{ '<span class="ec-font-bold">%count%件</span><span>の商品が見つかりました</span>'|trans({ '%count%': pagination.totalItemCount })|raw }}
  148.                     {% else %}
  149.                        <p style="padding: 5em 0;"> <span>{{ 'お探しの商品は見つかりませんでした'|trans }}</span></p>
  150.                     {% endif %}
  151.                 </div>
  152.                 {% if pagination.totalItemCount > 0 %}
  153.                     <div class="ec-searchnavRole__actions">
  154.                         <div class="ec-select">
  155.                             {{ form_widget(disp_number_form, {'id': '', 'attr': {'class': 'disp-number'}}) }}
  156.                             {{ form_widget(order_by_form, {'id': '', 'attr': {'class': 'order-by'}}) }}
  157.                         </div>
  158.                     </div>
  159.                 {% endif %}
  160.             </div>
  161.         </div>
  162.         {% if pagination.totalItemCount > 0 %}
  163.             <div class="ec-shelfRole">
  164.                 <ul class="ec-shelfGrid">
  165.                     {% for Product in pagination %}
  166.                         <li class="ec-shelfGrid__item">
  167.                             <a href="{{ url('product_detail', {'id': Product.id}) }}">
  168.                                 <p class="ec-shelfGrid__item-image">
  169.                                     <img src="{{ asset(Product.main_list_image|no_image_product, 'save_image') }}" alt="{{ Product.name }}" loading="lazy">
  170.                                 </p>
  171.                                 <p>{{ Product.name }}</p>
  172.                                 {% if Product.description_list %}
  173.                                     <p>{{ Product.description_list|raw|nl2br }}</p>
  174.                                 {% endif %}
  175.                                 <p class="price02-default">
  176.                                     {% if Product.hasProductClass %}
  177.                                         {% if Product.getPrice02Min == Product.getPrice02Max %}
  178.                                             {{ Product.getPrice02IncTaxMin|price }}
  179.                                         {% else %}
  180.                                             {{ Product.getPrice02IncTaxMin|price }} ~ {{ Product.getPrice02IncTaxMax|price }}
  181.                                         {% endif %}
  182.                                     {% else %}
  183.                                         {{ Product.getPrice02IncTaxMin|price }}
  184.                                     {% endif %}
  185.                                 </p>
  186.                             </a>
  187.                             {% if Product.stock_find %}
  188.                                 {% set form = forms[Product.id] %}
  189.                                 <form name="form{{ Product.id }}" id="productForm{{ Product.id }}" action="{{ url('product_add_cart', {id:Product.id}) }}" method="post">
  190.                                     <div class="ec-productRole__actions">
  191.                                         {% if form.classcategory_id1 is defined %}
  192.                                             <div class="ec-select">
  193.                                                 {{ form_widget(form.classcategory_id1) }}
  194.                                                 {{ form_errors(form.classcategory_id1) }}
  195.                                             </div>
  196.                                             {% if form.classcategory_id2 is defined %}
  197.                                                 <div class="ec-select">
  198.                                                     {{ form_widget(form.classcategory_id2) }}
  199.                                                     {{ form_errors(form.classcategory_id2) }}
  200.                                                 </div>
  201.                                             {% endif %}
  202.                                         {% endif %}
  203.                                         <div class="ec-numberInput"><span>{{ '数量'|trans }}</span>
  204.                                             {{ form_widget(form.quantity, {'attr': {'class': 'quantity'}}) }}
  205.                                             {{ form_errors(form.quantity) }}
  206.                                         </div>
  207.                                     </div>
  208.                                     {{ form_rest(form) }}
  209.                                 </form>
  210.                                 <div class="ec-productRole__btn">
  211.                                     <button type="submit" class="ec-blockBtn--action add-cart" data-cartid="{{ Product.id }}" form="productForm{{ Product.id }}">
  212.                                         {{ 'カートに入れる'|trans }}
  213.                                     </button>
  214.                                 </div>
  215.                             {% else %}
  216.                                 <div class="ec-productRole__btn">
  217.                                     <button type="button" class="ec-blockBtn--action" disabled="disabled">
  218.                                         {{ 'ただいま品切れ中です。'|trans }}
  219.                                     </button>
  220.                                 </div>
  221.                             {% endif %}
  222.                         </li>
  223.                     {% endfor %}
  224.                 </ul>
  225.             </div>
  226.             <div class="ec-modal">
  227.                 <div class="ec-modal-overlay">
  228.                     <div class="ec-modal-wrap">
  229.                         <span class="ec-modal-close"><span class="ec-icon"><img src="{{ asset('assets/icon/cross-dark.svg') }}" alt=""/></span></span>
  230.                         <div id="ec-modal-header" class="text-center">{{ 'カートに追加しました。'|trans }}</div>
  231.                         <div class="ec-modal-box">
  232.                             <div class="ec-role">
  233.                                 <span class="ec-inlineBtn--cancel">{{ 'お買い物を続ける'|trans }}</span>
  234.                                 <a href="{{ url('cart') }}" class="ec-inlineBtn--action">{{ 'カートへ進む'|trans }}</a>
  235.                             </div>
  236.                         </div>
  237.                     </div>
  238.                 </div>
  239.             </div>
  240.             
  241.             <div class="ec-pagerRole">
  242.                 {% include "pager.twig" with {'pages': pagination.paginationData} %}
  243.             </div>
  244.         {% endif %}
  245.     {% endif %}
  246. {% set Products = CustomizeCatProduct() %}
  247. <section class="categories white">
  248. <div class="wrap">
  249. <p class="clear">&nbsp;</p>
  250. <h2 class="subtitle"><strong class="fadein active"><i>C</i>ategories</strong>カテゴリー一覧</h2>
  251. <ul>
  252. {% if Products|length > 0 %}
  253.     {% for categorys in Products.category %}
  254.     
  255.     {%if categorys.ProductCategories|length != '0'%}
  256.     
  257.     {#% if categorys.Parent is same as(null)%#}
  258.     <li>
  259.     <a href="{{ url('product_list') }}?category_id={{categorys.id}}">
  260.     <div class="pic">
  261.     {% set num = categorys.id|sprintf_tow %}
  262.     {% set imgs = "assets/images/cat" ~ num ~ ".png" %}
  263.     
  264.     {%if categorys.category_image%}
  265.     <img src="{{ asset(categorys.category_image|no_image_product, 'save_image') }}" alt="{{ categorys.name }}" style="width:auto; height:100%;">
  266.     {%else%}
  267.     <img src="{{ asset(imgs, 'user_data') }}" alt="">
  268.     {%endif%}
  269.     </div>
  270.     <p>{{categorys.name|raw}}</p>
  271.     </a>
  272.     {#{dump(categorys)}#}
  273.     
  274.     </li>
  275.     {#% endif %#}
  276.     {% endif %}
  277.     
  278.     {% endfor %}
  279. {% endif %}
  280. </ul>
  281. </div>
  282. </section>
  283. {% endblock %}