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. {% set sidbar_out = false %}
  9. {% set sidebar_type = 0 %}
  10. {# 商品一覧からの場合 #}
  11. {% if Category is defined %}
  12. {% if Category is not null %}
  13.     {% for Path in Category.path %}
  14.         {% if Path.hierarchy == 1 %}
  15.             {% if Path.name == '部品' %}
  16.                 {% set sidebar_type = 1 %}
  17.                 {% set sidbar_out = true %}
  18.             {% endif %}
  19.             {% if Path.name == 'カートリッジ' %}
  20.                 {% set sidebar_type = 2 %}
  21.                 {% set sidbar_out = true %}
  22.             {% endif %}
  23.             {% if Path.name == '取付工事' %}
  24.                 {% set sidebar_type = 3 %}
  25.                 {% set sidbar_out = true %}
  26.             {% endif %}
  27.         {% endif %}
  28.     {% endfor %}
  29. {% else %}
  30.     {% set sidebar_type = 999 %}
  31. {% endif %}
  32. {% endif %}
  33. {% extends 'default_frame.twig' %}
  34. {% set body_class = 'product_page' %}
  35. {% block javascript %}
  36.     <script>
  37.         eccube.productsClassCategories = {
  38.             {% for Product in pagination %}
  39.             "{{ Product.id|escape('js') }}": {{ class_categories_as_json(Product)|raw }}{% if loop.last == false %}, {% endif %}
  40.             {% endfor %}
  41.         };
  42.         $(function() {
  43.             // 表示件数を変更
  44.             $('.disp-number').change(function() {
  45.                 var dispNumber = $(this).val();
  46.                 $('#disp_number').val(dispNumber);
  47.                 $('#pageno').val(1);
  48.                 $("#form1").submit();
  49.             });
  50.             // 並び順を変更
  51.             $('.order-by').change(function() {
  52.                 var orderBy = $(this).val();
  53.                 $('#orderby').val(orderBy);
  54.                 $('#pageno').val(1);
  55.                 $("#form1").submit();
  56.             });
  57.             $('.add-cart').on('click', function(e) {
  58.                 var $form = $(this).parents('li').find('form');
  59.                 // 個数フォームのチェック
  60.                 var $quantity = $form.parent().find('.quantity');
  61.                 if ($quantity.val() < 1) {
  62.                     $quantity[0].setCustomValidity('{{ '1以上で入力してください。'|trans }}');
  63.                     setTimeout(function() {
  64.                         loadingOverlay('hide');
  65.                     }, 100);
  66.                     return true;
  67.                 } else {
  68.                     $quantity[0].setCustomValidity('');
  69.                 }
  70.                 e.preventDefault();
  71.                 $.ajax({
  72.                     url: $form.attr('action'),
  73.                     type: $form.attr('method'),
  74.                     data: $form.serialize(),
  75.                     dataType: 'json',
  76.                     beforeSend: function(xhr, settings) {
  77.                         // Buttonを無効にする
  78.                         $('.add-cart').prop('disabled', true);
  79.                     }
  80.                 }).done(function(data) {
  81.                     // レスポンス内のメッセージをalertで表示
  82.                     $.each(data.messages, function() {
  83.                         $('#ec-modal-header').html(this);
  84.                     });
  85.                     $('.ec-modal').show()
  86.                     // カートブロックを更新する
  87.                     $.ajax({
  88.                         url: '{{ url('block_cart') }}',
  89.                         type: 'GET',
  90.                         dataType: 'html'
  91.                     }).done(function(html) {
  92.                         $('.ec-headerRole__cart').html(html);
  93.                     });
  94.                 }).fail(function(data) {
  95.                     alert('{{ 'カートへの追加に失敗しました。'|trans }}');
  96.                 }).always(function(data) {
  97.                     // Buttonを有効にする
  98.                     $('.add-cart').prop('disabled', false);
  99.                 });
  100.             });
  101.             
  102.             $('input.quantity').hide();
  103.             $('input.quantity').prev().hide();
  104.             $('select[name="classcategory_id1"]').hide();
  105.             $('select[name="classcategory_id2"]').hide();
  106.             $('select[name="classcategory_id3"]').hide();
  107.             $('select[name="classcategory_id4"]').hide();
  108.             $('select[name="classcategory_id5"]').hide();
  109.             $('#classcategory_id2').hide();
  110.             $('#classcategory_id3').hide();
  111.             $('#classcategory_id4').hide();
  112.             $('#classcategory_id5').hide();
  113.             $('.ec-modal-wrap').on('click', function(e) {
  114.                 // モーダル内の処理は外側にバブリングさせない
  115.                 e.stopPropagation();
  116.             });
  117.             $('.ec-modal-overlay, .ec-modal, .ec-modal-close, .ec-inlineBtn--cancel').on('click', function() {
  118.                 $('.ec-modal').hide()
  119.             });
  120.         });
  121.     </script>
  122. {% endblock %}
  123. {% block main %}
  124. <style>
  125.   .ec-shelfGrid .ec-shelfGrid__item-image{
  126.     height: auto;
  127.   }
  128. .ec-productRole__tag{
  129.     text-align: justify;
  130.     display: inline-block;
  131.     background-color: #ebf0f0;
  132.     padding: 1px 1px !important;
  133.     font-size: 90%;
  134.     margin-right: 5px;
  135. }
  136.   .ec-shelfGrid .ec-shelfGrid__item {
  137.     margin-bottom: 36px;
  138.     width: 100%;
  139.     display: -ms-flexbox;
  140.     display: flex;
  141.     -ms-flex-direction: column;
  142.         flex-direction: column; 
  143.   }
  144.         
  145.   @media only screen and (min-width: 768px){
  146.     .ec-shelfGrid .ec-shelfGrid__item{
  147.         padding: 0 16px;
  148. {% if sidebar_type == 1 or sidebar_type == 2  or sidebar_type == 3 or sidebar_type == 999 %}
  149.         width: 25%;
  150. {% else %}
  151.         width: 33%;
  152. {% endif %}
  153.     }
  154.   }
  155. </style>
  156.     {% if search_form.category_id.vars.errors|length > 0 %}
  157.         <div class="ec-searchnavRole">
  158.             <p class="errormsg text-danger">{{ 'ご指定のカテゴリは存在しません'|trans }}</p>
  159.         </div>
  160.     {% else %}
  161.         <div class="ec-searchnavRole">
  162.             <form name="form1" id="form1" method="get" action="?">
  163.                 {% for item in search_form %}
  164.                     <input type="hidden" id="{{ item.vars.id }}"
  165.                            name="{{ item.vars.full_name }}"
  166.                            {% if item.vars.value is not empty %}value="{{ item.vars.value }}" {% endif %}/>
  167.                 {% endfor %}
  168.             </form>
  169.             <div class="ec-searchnavRole__topicpath">
  170.                 <ol class="ec-topicpath">
  171.                     {# <li class="ec-topicpath__item"><a href="{{ url('product_list') }}">{{ '全て'|trans }}</a> #}
  172.                     {# </li> #}
  173.                     {% if Category is not null %}
  174.                         {% for Path in Category.path %}
  175.                             {# <li class="ec-topicpath__divider">|</li> #}
  176.                             <li class="ec-topicpath__item{% if loop.last %}--active{% endif %}"><a
  177.                                         href="{{ url('product_list') }}?category_id={{ Path.id }}">{{ Path.name }}</a>
  178.                             </li>
  179.                             <li class="ec-topicpath__divider">|</li>
  180.                         {% endfor %}
  181.                     {% endif %}
  182.                     {#{% if search_form.vars.value and search_form.vars.value.name %}#}
  183.                     {#    <li class="ec-topicpath__divider">|</li>#}
  184.                     {#    <li class="ec-topicpath__item">{{ '「%name%」の検索結果'|trans({ '%name%': search_form.vars.value.name }) }}</li>#}
  185.                     {#{% endif %}#}
  186.                 </ol>
  187.             </div>
  188.             <div class="ec-searchnavRole__infos">
  189.                 {#<div class="ec-searchnavRole__counter">#}
  190.                 {#    {% if pagination.totalItemCount > 0 %}#}
  191.                 {#        {{ '<span class="ec-font-bold">%count%件</span><span>の商品が見つかりました</span>'|trans({ '%count%': pagination.totalItemCount })|raw }}#}
  192.                 {#    {% else %}#}
  193.                 {#        <span>{{ 'お探しの商品は見つかりませんでした'|trans }}</span>#}
  194.                 {#    {% endif %}#}
  195.                 {#</div>#}
  196.                 {#{% if pagination.totalItemCount > 0 %}#}
  197.                 {#    <div class="ec-searchnavRole__actions">#}
  198.                 {#        <div class="ec-select">#}
  199.                 {#            {{ form_widget(disp_number_form, {'id': '', 'attr': {'class': 'disp-number'}}) }}#}
  200.                 {#            {{ form_widget(order_by_form, {'id': '', 'attr': {'class': 'order-by'}}) }}#}
  201.                 {#        </div>#}
  202.                 {#    </div>#}
  203.                 {#{% endif %}#}
  204.             </div>
  205.         </div>
  206.         {% if pagination.totalItemCount > 0 %}
  207.             <div class="ec-shelfRole">
  208.                 <ul class="ec-shelfGrid">
  209.                     {% for Product in pagination %}
  210.                         <li class="ec-shelfGrid__item">
  211.                                 <p class="ec-shelfGrid__item-image">
  212.                             <a href="{{ url('product_detail', {'id': Product.id}) }}">
  213.                                 <p class="ec-shelfGrid__item-image">
  214.                                     <img src="{{ asset(Product.main_list_image|no_image_product, 'save_image') }}" alt="{{ Product.name }}" loading="lazy">
  215.                                 </p>
  216. {# 部品の場合 #}
  217. {% if sidebar_type == 1 %}
  218.                     {% if Product.code_min is not empty %}
  219.                         {#<p style="font-size: 12px;">型番<br /></p>#}
  220.                         <span class="product-code-default">{{ Product.code_min }}{% if Product.code_min != Product.code_max %} ~ {{ Product.code_max }}{% endif %}</span>
  221.                     {% endif %}
  222. {% endif %}    
  223.                                 <p>{{ Product.name }}</p>
  224.                                 {% if Product.description_list %}
  225.                                     <p>{{ Product.description_list|raw|nl2br }}</p>
  226.                                 {% endif %}
  227.                                 <p>
  228.                                     {% set flgRental = false %}
  229.                                     {% for class in Product.ProductClasses %}
  230.                                         {% if CustomSaleType[class.SaleType.Id] is defined %}
  231.                                         {% if CustomSaleType[class.SaleType.Id].Rental %}
  232.                                             
  233.                                             {% set flgRental = true %}
  234.                                         {% endif %}
  235.                                         {% endif %}
  236.                                     {% endfor %}
  237.                                     {% if flgRental %}
  238.                                     レンタル月額
  239.                                     {% endif %}
  240.                                 </p>
  241.                                 <p class="xxxx">
  242.                                    {{ Product.getPrice02IncTaxMax|number_format }}円税込
  243.                                 </p>
  244.                                 <p class="xxxx">
  245.                                     {% if Product.hasProductClass %}
  246.                                         {% if Product.getPrice02Min == Product.getPrice02Max %}
  247.                                         {% else %}
  248.                                             <span class="txt" style="font-size: 10px;">(オートシップメント契約価格{{ Product.getPrice02IncTaxMin|number_format }}円税込)</span>
  249.                                         {% endif %}
  250.                                     {% else %}
  251.                                     {% endif %}
  252.                                 </p>
  253.                             {# タグ #}
  254.                             <ul class="ec-productRole__tags">
  255.                                 {% for Tag in Product.Tags %}
  256.                                     <li class="ec-productRole__tag tag_{{ Tag.id }}">{{ Tag }}</li>
  257.                                     {% if loop.last %}
  258.                                     {% else %}
  259.                                     /
  260.                                     {% endif %}
  261.                                 {% endfor %}
  262.                             </ul>
  263.                             {# タグ #}
  264.                             {% if Product.stock_find %}
  265.                                 {#{% set form = forms[Product.id] %}#}
  266.                                 {#<form name="form{{ Product.id }}" id="productForm{{ Product.id }}" action="{{ url('product_add_cart', {id:Product.id}) }}" method="post">#}
  267.                                     {#<div class="ec-productRole__actions">#}
  268.                                         {#{% if form.classcategory_id1 is defined %}#}
  269.                                             {#<div class="ec-select">#}
  270.                                                 {#{{ form_widget(form.classcategory_id1) }}#}
  271.                                                 {#{{ form_errors(form.classcategory_id1) }}#}
  272.                                             {#</div>#}
  273.                                             {#{% if form.classcategory_id2 is defined %}#}
  274.                                                 {#<div class="ec-select">#}
  275.                                                     {#{{ form_widget(form.classcategory_id2) }}#}
  276.                                                     {#{{ form_errors(form.classcategory_id2) }}#}
  277.                                                 {#</div>#}
  278.                                             {#{% endif %}#}
  279.                                         {#{% endif %}#}
  280.                                         {#<div class="ec-numberInput"><span>{{ '数量'|trans }}</span>#}
  281.                                             {#{{ form_widget(form.quantity, {'attr': {'class': 'quantity'}}) }}#}
  282.                                             {#{{ form_errors(form.quantity) }}#}
  283.                                         {#</div>#}
  284.                                     {#</div>#}
  285.                                     {#{{ form_rest(form) }}#}
  286.                                 {#</form>#}
  287.                                 <div class="ec-productRole__btn">
  288.                                     {#{% set flgCartridge = false %}#}
  289.                                     {#{% for class in Product.ProductClasses %}#}
  290.                                     {#    {% if CustomSaleType[class.SaleType.Id] is defined %}#}
  291.                                     {#    {% if CustomSaleType[class.SaleType.Id].ExchageCartridge %}#}
  292.                                     {#        {% set flgCartridge = true %}#}
  293.                                     {#    {% endif %}#}
  294.                                     {#    {% endif %}#}
  295.                                     {#{% endfor %}#}
  296.                                     {#{% if Product.IsChangeCartridge %}#}
  297.                                     {#    {% if flgCartridge %}#}
  298.                                     {#    <p style="color:red">{{ 'customize.cartridge.replacement.supplement.message'|trans }}</p>#}
  299.                                     {#    {% endif %}#}
  300.                                     {#{% endif %}#}
  301.                                     {#{% if Product.IsRental %}#}
  302.                                     {#{% else %}#}
  303.                                     {#<button type="submit" class="ec-blockBtn--action add-cart" data-cartid="{{ Product.id }}" form="productForm{{ Product.id }}">#}
  304.                                     {#    {{ 'カートに入れる'|trans }}#}
  305.                                     {#</button>#}
  306.                                     {#{% endif %}#}
  307.                                 </div>
  308.                                 {% else %}
  309.                                 {#<div class="ec-productRole__btn">#}
  310.                                 {#    <button type="button" class="ec-blockBtn--action" disabled="disabled">#}
  311.                                 {#        {{ 'ただいま品切れ中です。'|trans }}#}
  312.                                 {#    </button>#}
  313.                                 {#</div>#}
  314.                             {% endif %}
  315.                         </li>
  316.                     {% endfor %}
  317.                 </ul>
  318.             </div>
  319.             <div class="ec-modal">
  320.                 <div class="ec-modal-overlay">
  321.                     <div class="ec-modal-wrap">
  322.                         <span class="ec-modal-close"><span class="ec-icon"><img src="{{ asset('assets/icon/cross-dark.svg') }}" alt=""/></span></span>
  323.                         <div id="ec-modal-header" class="text-center">{{ 'カートに追加しました。'|trans }}</div>
  324.                         <div class="ec-modal-box">
  325.                             <div class="ec-role">
  326.                                 <span class="ec-inlineBtn--cancel">{{ 'お買い物を続ける'|trans }}</span>
  327.                                 <a href="{{ url('cart') }}" class="ec-inlineBtn--action">{{ 'カートへ進む'|trans }}</a>
  328.                             </div>
  329.                         </div>
  330.                     </div>
  331.                 </div>
  332.             </div>
  333.             <div class="ec-pagerRole">
  334.                 {% include "pager.twig" with {'pages': pagination.paginationData} %}
  335.             </div>
  336.         {% endif %}
  337.     {% endif %}
  338. {% endblock %}