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. {% set hasCategory = false %}
  11. {% set request_uri = app.request.server.get('REQUEST_URI') %}
  12. {% if 'name=' in request_uri and Category != "" %}
  13.     {% set RootCategory = Category.RootCategory %}
  14.     {% set hasCategory = true %}
  15.     {% set msg = "elseif 'name=' in request_uri and Category != ))" %}
  16. {% elseif  Category != "" %}
  17.     {% set RootCategory = Category.RootCategory %}
  18.     {% set hasCategory = true %}
  19.     {% set msg = "elseif  Category != ))" %}
  20. {% elseif 'name=' in request_uri %}
  21.     {% set hasCategory = false %}
  22.     {% set msg = "if 'name=' in request_uri" %}
  23. {% else %}
  24.     {% set msg = "else" %}
  25. {% endif %}
  26. {% if hasCategory %}
  27.     {% set RootCategory = Category.RootCategory %}
  28. {% endif %}
  29. {% set prm2 = app.request.query.get('type') %}
  30. {% set prm3 = app.request.query.get('category_id2') %}
  31. {% set prm4 = app.request.query.get('category_id3') %}
  32. {% set prm5 = app.request.query.get('category_id4') %}
  33. {% set prm6 = app.request.query.get('category_id5') %}
  34. {% set prm7 = app.request.query.get('tag_id') %}
  35. {% set pm2 = cast_to_int(prm2) %}
  36. {% set pm3 = cast_to_int(prm3) %}
  37. {% set pm4 = cast_to_int(prm4) %}
  38. {% set pm5 = cast_to_int(prm5) %}
  39. {% set pm6 = cast_to_int(prm6) %}
  40. {% set cn1 = app.request.query.get('name') %}
  41. {% if prm2 == 0 and prm2 != "" %}
  42.     {% set cn2 = "ヴァイスシュヴァルツ," %}
  43. {% elseif prm2 == 1 and prm2 != "" %}
  44.     {% set cn2 = "ポケモン," %}
  45. {% else %}
  46.     {% set cn2 = "" %}
  47. {% endif %}
  48. {% set cn3 = get_category_name(pm3) %}
  49. {% set cn4 = get_category_name(pm4) %}
  50. {% set cn5 = get_category_name(pm5) %}
  51. {% set cn6 = get_category_name(pm6) %}
  52. {% if prm7 == 4 and prm7 != "" %}
  53.     {% set cn7 = "傷あり商品," %}
  54. {% else %}
  55.     {% set cn7 = "" %}
  56. {% endif %}
  57. {% block javascript %}
  58.     <script>
  59.         eccube.productsClassCategories = {
  60.             {% for Product in pagination %}
  61.             "{{ Product.id|escape('js') }}": {{ class_categories_as_json(Product)|raw }}{% if loop.last == false %}, {% endif %}
  62.             {% endfor %}
  63.         };
  64.         $(function() {
  65.             // 表示件数を変更
  66.             $('.disp-number').change(function() {
  67.                 var dispNumber = $(this).val();
  68.                 $('#disp_number').val(dispNumber);
  69.                 $('#pageno').val(1);
  70.                 $("#form1").submit();
  71.             });
  72.             // 並び順を変更
  73.             $('.order-by').change(function() {
  74.                 var orderBy = $(this).val();
  75.                 $('#orderby').val(orderBy);
  76.                 $('#pageno').val(1);
  77.                 $("#form1").submit();
  78.             });
  79.             $('.add-cart').on('click', function(e) {
  80.                 var $form = $(this).parents('li').find('form');
  81.                 // 個数フォームのチェック
  82.                 var $quantity = $form.parent().find('.quantity');
  83.                 if ($quantity.val() < 1) {
  84.                     $quantity[0].setCustomValidity('{{ 'front.product.invalid_quantity'|trans }}');
  85.                     setTimeout(function() {
  86.                         loadingOverlay('hide');
  87.                     }, 100);
  88.                     return true;
  89.                 } else {
  90.                     $quantity[0].setCustomValidity('');
  91.                 }
  92.                 e.preventDefault();
  93.                 $.ajax({
  94.                     url: $form.attr('action'),
  95.                     type: $form.attr('method'),
  96.                     data: $form.serialize(),
  97.                     dataType: 'json',
  98.                     beforeSend: function(xhr, settings) {
  99.                         // Buttonを無効にする
  100.                         $('.add-cart').prop('disabled', true);
  101.                     }
  102.                 }).done(function(data) {
  103.                     // レスポンス内のメッセージをalertで表示
  104.                     $.each(data.messages, function() {
  105.                         $('#ec-modal-header').text(this);
  106.                     });
  107.                     $('.ec-modal').show()
  108.                     // カートブロックを更新する
  109.                     $.ajax({
  110.                         url: '{{ url('block_cart') }}',
  111.                         type: 'GET',
  112.                         dataType: 'html'
  113.                     }).done(function(html) {
  114.                         $('.ec-headerRole__cart').html(html);
  115.                     });
  116.                 }).fail(function(data) {
  117.                     alert('{{ 'front.product.add_cart_error'|trans }}');
  118.                 }).always(function(data) {
  119.                     // Buttonを有効にする
  120.                     $('.add-cart').prop('disabled', false);
  121.                 });
  122.             });
  123.         });
  124.         $('.ec-modal-wrap').on('click', function(e) {
  125.             // モーダル内の処理は外側にバブリングさせない
  126.             e.stopPropagation();
  127.         });
  128.         $('.ec-modal-overlay, .ec-modal, .ec-modal-close, .ec-inlineBtn--cancel').on('click', function() {
  129.             $('.ec-modal').hide()
  130.         });
  131.         {% if hasCategory %}
  132.             {% if RootCategory == "買い取り" or Category == "買い取り" %}
  133.                 $('.bigbox').css('background-color','#22b573');
  134.                 $('.header-middle').css('background-color','#22b573');
  135.                 $('.side-searchbox').css('background-color','#22b573');
  136.                 $('.side-cat-more').css('background-color','#22b573');
  137.                 $('.side-cat-more2').css('background-color','#22b573');
  138.                 $('.side-cat-more3').css('background-color','#22b573');
  139.             {% endif %}
  140.         {% endif %}
  141.         $(document).ready(function() {
  142.           // プラスボタンがクリックされたとき
  143.           $('.spinner-up').click(function() {
  144.             // 対応する数量フィールドのIDを取得
  145.             var productId = $(this).closest('.number-spinner-wrap').find('input[type="number"]').attr('id');
  146.             
  147.             // 対応する数量フィールドの値を取得
  148.             var quantity = parseInt($('#' + productId).val());
  149.         
  150.             // 値を増加させて数量フィールドに設定
  151.             $('#' + productId).val(quantity + 1);
  152.           });
  153.         
  154.           // マイナスボタンがクリックされたとき
  155.           $('.spinner-down').click(function() {
  156.             // 対応する数量フィールドのIDを取得
  157.             var productId = $(this).closest('.number-spinner-wrap').find('input[type="number"]').attr('id');
  158.             
  159.             // 対応する数量フィールドの値を取得
  160.             var quantity = parseInt($('#' + productId).val());
  161.         
  162.             // 値を減少させて数量フィールドに設定 (1未満にはしない)
  163.             if (quantity > 1) {
  164.               $('#' + productId).val(quantity - 1);
  165.             }
  166.           });
  167.         });
  168.     </script>
  169. {% endblock %}
  170. {% block main %}
  171.     <div class="ec-layoutRole__mainTop">
  172.        
  173.         <div class="top-content-box cat_mob_top-content-box">
  174.         {% if search_form.category_id.vars.errors|length > 0 %}
  175.             <div class="test">
  176.                 <p class="errormsg text-danger">{{ 'front.product.search__category_not_found'|trans }}</p>
  177.             </div>
  178.         {% else %}
  179.             <div class="sort-big-box">
  180.                 <h2>商品一覧</h2>
  181.                     <div class="sort-box">
  182.                     <!--<a href="{{ app.request.getUri }}&orderby=4">おすすめ順</a>-->
  183.                         <a href="{{ app.request.getUri }}&orderby=2">新着順</a>
  184.                         <a href="{{ app.request.getUri }}&orderby=1">価格の安い順</a>
  185.                         <a href="{{ app.request.getUri }}&orderby=3">価格の高い順</a>
  186.                     </div>
  187.                 {% if cn1 is empty and  cn2 is empty and  cn3 is empty and  cn4 is empty and  cn5 is empty and  cn6 is empty %}
  188.                 {% else %}
  189.                     <p class="search_res_text">検索ワード:{{ cn2 }}{{ cn3 }}{{ cn4 }}{{ cn5 }}{{ cn6 }}{{ cn7 }}{{ cn1 }}</p>
  190.                 {% endif %}
  191.             </div>
  192.             <div class="product-big-list">
  193.                 
  194.             {% if pagination.totalItemCount > 0 %}
  195.                     {% for Product in pagination %}
  196.                     <div class="product-list-box">
  197.                             {% if app.request.query.get('category_id') == 219 or app.request.query.get('category_id') == 218 %}
  198.                                     <img src="{{ asset(Product.main_list_image|no_image_product, 'save_image') }}">
  199.                             {% else %}
  200.                                 <a href="{{ url('product_detail', {'id': Product.id}) }}">
  201.                                     <img src="{{ asset(Product.main_list_image|no_image_product, 'save_image') }}">
  202.                                 </a>
  203.                             {% endif %}
  204.                             <p>{{ Product.name }}</p>
  205.                             <p class="price">
  206.                                 {% if Product.hasProductClass %}
  207.                                     {% if Product.getPrice02Min == Product.getPrice02Max %}
  208.                                         {{ Product.getPrice02IncTaxMin|number_format }}
  209.                                     {% else %}
  210.                                         {{ Product.getPrice02IncTaxMin|number_format }} ~ {{ Product.getPrice02IncTaxMax|number_format }}
  211.                                     {% endif %}
  212.                                 {% else %}
  213.                                     {{ Product.getPrice02IncTaxMin|number_format }}
  214.                                 {% endif %}
  215.                                 <span>円</span>
  216.                             </p>
  217.                             {% if Product.stock_find %}
  218.                                 <form name="form{{ Product.id }}" id="productForm{{ Product.id }}" action="{{ url('product_add_cart', {id:Product.id}) }}" method="post">
  219.                                         {% if hasCategory %}
  220.                                             {% if RootCategory == "買い取り" or Category == "買い取り" %}
  221.                                                 <input type="hidden" name="buyflg" value="1">
  222.                                             {% else %}
  223.                                             {% endif %}
  224.                                         {% endif %}
  225.                                     <label class="number-spinner-wrap">
  226.                                         <input type="number" id="quantity{{ Product.id }}" name="quantity" required="required" min="1" maxlength="9" class="test5" value="1">
  227.                                         <span class="spinner spinner-down"> <img src="{{ asset('/html/user_data/assets/img/minus.png') }}" class="numcursul" alt=""> </span>
  228.                                         <span class="spinner spinner-up"> <img src="{{ asset('/html/user_data/assets/img/plus.png') }}" class="numcursul" alt=""> </span>
  229.                                     </label>
  230.                                     <input type="hidden" id="product_id{{ Product.id }}" name="product_id" value="{{ Product.id }}">
  231.                                     <input type="hidden" id="ProductClass" name="ProductClass" value="{{ Product.ProductClasses[0].id }}">
  232.                                     <input type="hidden" id="_token{{ Product.id }}" name="_token" value="{{ csrf_token('Eccube\\Form\\Type\\AddCartType') }}" />
  233.                                 </form>
  234.                                     {% if hasCategory %}
  235.                                         {% if RootCategory == "買い取り" or Category == "買い取り" %}
  236.                                             <div class="cart-in-btn">
  237.                                                 <button class="add-cart-custom" data-cartid="{{ Product.id }}" form="productForm{{ Product.id }}" type="submit"> 売却する </button>
  238.                                             </div>
  239.                                         {% else %}
  240.                                             <div class="cart-in-btn">
  241.                                                 <button class="add-cart-custom" data-cartid="{{ Product.id }}" form="productForm{{ Product.id }}" type="submit"> カートに入れる </button>
  242.                                             </div>
  243.                                         {% endif %}
  244.                                     {% endif %}
  245.                                     
  246.                                     
  247.                                 
  248.                             {% else %}
  249.                                 <div class="cart-in-btn">
  250.                                     <button type="button" class="add-cart-custom" disabled="disabled"> {{ '品切れ中'|trans }} </button>
  251.                                 </div>
  252.                             {% endif %}
  253.                         </div>
  254.                         <!--<li class="ec-shelfGrid__item">
  255.                             <a href="{{ url('product_detail', {'id': Product.id}) }}">
  256.                                 <p class="ec-shelfGrid__item-image">
  257.                                     <img src="{{ asset(Product.main_list_image|no_image_product, 'save_image') }}" alt="{{ Product.name }}" {% if loop.index > 5 %} loading="lazy"{% endif %}>
  258.                                 </p>
  259.                                 <p>{{ Product.name }}</p>
  260.                                 {% if Product.description_list %}
  261.                                     <p>{{ Product.description_list|raw|nl2br }}</p>
  262.                                 {% endif %}
  263.                                 <p class="price02-default">
  264.                                     {% if Product.hasProductClass %}
  265.                                         {% if Product.getPrice02Min == Product.getPrice02Max %}
  266.                                             {{ Product.getPrice02IncTaxMin|price }}
  267.                                         {% else %}
  268.                                             {{ Product.getPrice02IncTaxMin|price }} ~ {{ Product.getPrice02IncTaxMax|price }}
  269.                                         {% endif %}
  270.                                     {% else %}
  271.                                         {{ Product.getPrice02IncTaxMin|price }}
  272.                                     {% endif %}
  273.                                 </p>
  274.                             </a>
  275.                             {% if Product.stock_find %}
  276.                                 {% set form = forms[Product.id] %}
  277.                                 <form name="form{{ Product.id }}" id="productForm{{ Product.id }}" action="{{ url('product_add_cart', {id:Product.id}) }}" method="post">
  278.                                     <div class="ec-productRole__actions">
  279.                                         {% if form.classcategory_id1 is defined %}
  280.                                             <div class="ec-select">
  281.                                                 {{ form_widget(form.classcategory_id1) }}
  282.                                                 {{ form_errors(form.classcategory_id1) }}
  283.                                             </div>
  284.                                             {% if form.classcategory_id2 is defined %}
  285.                                                 <div class="ec-select">
  286.                                                     {{ form_widget(form.classcategory_id2) }}
  287.                                                     {{ form_errors(form.classcategory_id2) }}
  288.                                                 </div>
  289.                                             {% endif %}
  290.                                         {% endif %}
  291.                                         <div class="ec-numberInput"><span>{{ 'common.quantity'|trans }}</span>
  292.                                             {{ form_widget(form.quantity, {'attr': {'class': 'quantity'}}) }}
  293.                                             {{ form_errors(form.quantity) }}
  294.                                         </div>
  295.                                     </div>
  296.                                     {{ form_rest(form) }}
  297.                                 </form>
  298.                                 <div class="ec-productRole__btn">
  299.                                     <button type="submit" class="ec-blockBtn--action add-cart" data-cartid="{{ Product.id }}" form="productForm{{ Product.id }}">
  300.                                         {{ 'front.product.add_cart'|trans }}
  301.                                     </button>
  302.                                 </div>
  303.                             {% else %}
  304.                                 <div class="ec-productRole__btn">
  305.                                     <button type="button" class="ec-blockBtn--action" disabled="disabled">
  306.                                         {{ 'front.product.out_of_stock'|trans }}
  307.                                     </button>
  308.                                 </div>
  309.                             {% endif %}
  310.                         </li>-->
  311.                     {% endfor %}
  312.                 </div>
  313.                 <div class="ec-modal">
  314.                     <div class="ec-modal-overlay">
  315.                         <div class="ec-modal-wrap">
  316.                             <span class="ec-modal-close"><span class="ec-icon"><img src="{{ asset('assets/icon/cross-dark.svg') }}" alt=""/></span></span>
  317.                             <div id="ec-modal-header" class="text-center">{{ 'front.product.add_cart_complete'|trans }}</div>
  318.                             <div class="ec-modal-box">
  319.                                 <div class="ec-role">
  320.                                     <span class="ec-inlineBtn--cancel">{{ 'front.product.continue'|trans }}</span>
  321.                                     <a href="{{ url('cart') }}" class="ec-inlineBtn--action">{{ 'common.go_to_cart'|trans }}</a>
  322.                                 </div>
  323.                             </div>
  324.                         </div>
  325.                     </div>
  326.                 </div>
  327.                 <div class="ec-pagerRole">
  328.                     {% include "pager.twig" with {'pages': pagination.paginationData} %}
  329.                 </div>
  330.             {% endif %}
  331.         {% endif %}
  332.         </div>
  333.     </div>
  334. {% endblock %}