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. <style>
  88.     .status_icon_topright {
  89.         position: absolute;
  90.         top: 0;
  91.         right: 0;
  92.         left: auto;
  93.         width: 60px;
  94.         height: 60px;
  95.     }
  96.     .status_icon_bottomleft {
  97.         position: absolute;
  98.         bottom: 0;
  99.         right: auto;
  100.         left: 0;
  101.         width: 60px;
  102.         height: 60px;
  103.     }
  104. </style>
  105. {% if search_form.category_id.vars.errors|length > 0 %}
  106.         <div class="ec-searchnavRole">
  107.             <p class="errormsg text-danger">{{ 'ご指定のカテゴリは存在しません'|trans }}</p>
  108.         </div>
  109.     {% else %}
  110.         <div class="ec-searchnavRole">
  111.             <form name="form1" id="form1" method="get" action="?">
  112.                 {% for item in search_form %}
  113.                     <input type="hidden" id="{{ item.vars.id }}"
  114.                            name="{{ item.vars.full_name }}"
  115.                            {% if item.vars.value is not empty %}value="{{ item.vars.value }}" {% endif %}/>
  116.                 {% endfor %}
  117.             </form>
  118.             <div class="ec-searchnavRole__topicpath">
  119.                 <ol class="ec-topicpath">
  120.                     <li class="ec-topicpath__item"><a href="{{ url('product_list') }}">{{ '全て'|trans }}</a>
  121.                     </li>
  122.                     {% if Category is not null %}
  123.                         {% for Path in Category.path %}
  124.                             <li class="ec-topicpath__divider">|</li>
  125.                             <li class="ec-topicpath__item{% if loop.last %}--active{% endif %}"><a
  126.                                         href="{{ url('product_list') }}?category_id={{ Path.id }}">{{ Path.name }}</a>
  127.                             </li>
  128.                         {% endfor %}
  129.                     {% endif %}
  130.                     {# パンくずリストに検索条件の内容も追加する。検索ワード、タグ、価格帯。 #}
  131.                     {% if search_form.vars.value and (search_form.vars.value.name or search_form.vars.value.tag_id or search_form.vars.value.price_id) %}
  132.                         <li class="ec-topicpath__item">{{ ' 検索条件'|trans }}</li>
  133.                         {% if search_form.vars.value and search_form.vars.value.name %}
  134.                             <li class="ec-topicpath__item">{{ '「%name%」'|trans({ '%name%': search_form.vars.value.name }) }}</li>
  135.                         {% endif %}
  136.                         {% if search_form.vars.value and search_form.vars.value.tag_id %}
  137.                             {% set Tags = repository('Eccube\\Entity\\Tag').getList() %}
  138.                             {% set now_tag_id = app.request.query.get('tag_id') %}
  139.                             {% set current_tag = Tags|filter(tag => tag.id == now_tag_id)|first %}
  140.                             {% if current_tag %}
  141.                                 <li class="ec-topicpath__item">{{ '「%Tag.name%」'|trans({ '%Tag.name%': current_tag.name }) }}</li>
  142.                             {% endif %}
  143.                         {% endif %}
  144.                         {% if search_form.vars.value and search_form.vars.value.price_id %}
  145.                             {% set price_ranges = {
  146.                                 1: '10万円未満',
  147.                                 2: '10万円以上~20万円未満',
  148.                                 3: '20万円以上~30万円未満',
  149.                                 4: '30万円以上~50万円未満',
  150.                                 5: '50万円以上~100万円未満',
  151.                                 6: '100万円以上',
  152.                             } %}
  153.                             {% set now_price_id = app.request.query.get('price_id') %}
  154.                             {% if price_ranges[now_price_id] is defined %}
  155.                                 <li class="ec-topicpath__item">{{ '「%price_range%」'|trans({ '%price_range%': price_ranges[now_price_id] }) }}</li>
  156.                             {% endif %}
  157.                         {% endif %}
  158.                     {% endif %}
  159.                 </ol>
  160.             </div>
  161.             {# 商品一覧ページのサーチフィルター部分のブロックを挿入。 #}
  162.             {% include 'Block/product_list_filter.twig' %}
  163.             <div class="ec-searchnavRole__infos">
  164.                 <div class="ec-searchnavRole__counter">
  165.                     {% if pagination.totalItemCount > 0 %}
  166.                         {{ '<span class="ec-font-bold">%count%件</span><span>の商品が見つかりました</span>'|trans({ '%count%': pagination.totalItemCount })|raw }}
  167.                     {% else %}
  168.                         <span>{{ 'お探しの商品は見つかりませんでした'|trans }}</span>
  169.                     {% endif %}
  170.                 </div>
  171.                 {% if pagination.totalItemCount > 0 %}
  172.                     <div class="ec-searchnavRole__actions">
  173.                         <div class="ec-select">
  174.                             {{ form_widget(search_form.disp_number, {'id': '', 'attr': {'class': 'disp-number'}}) }}
  175.                             {{ form_widget(search_form.orderby, {'id': '', 'attr': {'class': 'order-by'}}) }}
  176.                         </div>
  177.                     </div>
  178.                 {% endif %}
  179.             </div>
  180.         </div>
  181.         {% if pagination.totalItemCount > 0 %}
  182.             <div class="ec-shelfRole">
  183.                 <ul class="ec-shelfGrid">
  184.                     {% for Product in pagination %}
  185.                         <li class="ec-shelfGrid__item">
  186.                             <a href="{{ url('product_detail', {'id': Product.id}) }}">
  187.                                 <p class="ec-shelfGrid__item-image" style="position:relative;">
  188.                                     <img src="{{ asset(Product.main_list_image|no_image_product, 'save_image') }}" alt="{{ Product.name }}" {% if loop.index > 5 %} loading="lazy"{% endif %}>
  189.                                     {# 商品一覧画像に、商品タグに合わせた画像をオーバーレイする。 #}
  190.                                     {% if Product.Tags is not empty %}
  191.                                         {% if Product.Tags|filter(tag => tag.id == 6)|length > 0 %} {# id=6、特価品(在庫のみ) #}
  192.                                             <img src="{{ asset('assets/img/productlist/itemlist_icon_sale-instock.png') }}" alt="Small Image" class="status_icon_bottomleft" />
  193.                                         {% endif %}
  194.                                         {% if Product.Tags|filter(tag => tag.id == 7)|length > 0 %} {# id=7、特価品(取り寄せ対応) #}
  195.                                             <img src="{{ asset('assets/img/productlist/itemlist_icon_sale-order.png') }}" alt="Small Image" class="status_icon_bottomleft" />
  196.                                         {% endif %}
  197.                                         {% if Product.Tags|filter(tag => tag.id == 8)|length > 0 %} {# id=8、アウトレット品 #}
  198.                                             <img src="{{ asset('assets/img/productlist/itemlist_icon_outlet.png') }}" alt="Small Image" class="status_icon_bottomleft" />
  199.                                         {% endif %}
  200.                                         {% if Product.Tags|filter(tag => tag.id == 9)|length > 0 %} {# id=9、在庫品 #}
  201.                                             <img src="{{ asset('assets/img/productlist/itemlist_icon_instock.png') }}" alt="Small Image" class="status_icon_topright" />
  202.                                         {% endif %}
  203.                                         {% if Product.Tags|filter(tag => tag.id == 10)|length > 0 %} {# id=10、メーカー取寄せ #}
  204.                                             <img src="{{ asset('assets/img/productlist/itemlist_icon_order.png') }}" alt="Small Image" class="status_icon_topright" />
  205.                                         {% endif %}
  206.                                     {% endif %}
  207.                                 </p>
  208.                                 {% if Product.Maker %} 
  209.                                     <p class="ec-shelfGrid__item-maker">{{ Product.Maker.nameEn }}</p>
  210.                                 {% endif %}
  211.                                 <p>
  212.                                     {{ Product.name }}
  213.                                     {% if Product.model_year %} 
  214.                                         {{ Product.model_year }}{{ '年モデル'|trans }}
  215.                                     {% endif %}
  216.                                 </p>
  217.                                 {% if Product.description_list %}
  218.                                     <!--<p>{{ Product.description_list|raw|nl2br }}</p>-->
  219.                                 {% endif %}
  220.                                 {# 定価表示と現金特価で表示ラベルを変更する。 #}
  221.                                 {% if Product.ask_price == 'teika_price' %} 
  222.                                     <p class="ec-color-red">{{ '販売価格(税込)' }}</p>
  223.                                 {% else %}
  224.                                     <p class="ec-color-red">{{ '現金特価(税込)'|trans }}</p>
  225.                                 {% endif %}
  226.                                 {# 商品の価格・カート表示フラグに応じた表記にする。 #}
  227.                                 <p class="price02-default"><strong class="ec-color-red ec-font-size-4">
  228.                                     {% if Product.hasProductClass %}
  229.                                     {# 規格を持つ商品の場合の処理 #}
  230.                                         {% if Product.ask_price == 'teika_price' %}
  231.                                             {% if Product.getPrice01Min == Product.getPrice01Max %}
  232.                                                 {{ Product.Price01IncTaxMin|price }}
  233.                                             {% else %}
  234.                                                 {{ Product.Price01IncTaxMin|price }} ~
  235.                                             {% endif %}
  236.                                         {% elseif Product.ask_price == 'hidden_price' %}
  237.                                             {% if Product.info_comment2 is null %}
  238.                                                 {{ 'びっくり大特価!'|trans }}
  239.                                             {% else %}
  240.                                                 {{ Product.info_comment2|trans }}
  241.                                             {% endif %}
  242.                                         {% else %}
  243.                                             {% if Product.getPrice02Min == Product.getPrice02Max %}
  244.                                                 {{ (Product.getPrice02IncTaxMin / 1.05)|price }}
  245.                                             {% else %}
  246.                                                 {{ (Product.getPrice02IncTaxMin / 1.05)|price }} ~
  247.                                             {% endif %}
  248.                                         {% endif %}
  249.                                     {% else %}
  250.                                     {# 規格を持たない商品の場合の処理 #}
  251.                                         {% if Product.ask_price == 'teika_price' %}
  252.                                             {{ (Product.getPrice01IncTaxMin)|price }}
  253.                                         {% elseif Product.ask_price == 'hidden_price' %}
  254.                                             {% if Product.info_comment2 is null %}
  255.                                                 {{ 'びっくり大特価!'|trans }}
  256.                                             {% else %}
  257.                                                 {{ Product.info_comment2|trans }}
  258.                                             {% endif %}
  259.                                         {% else %}
  260.                                             {{ (Product.getPrice02IncTaxMin / 1.05)|price }}
  261.                                         {% endif %}
  262.                                     {% endif %}
  263.                                 {# end 商品の価格・カート表示フラグに応じた表記にする。 #}
  264.                                 </strong></p>
  265.                                 {# 定価表示を追加する。 #}
  266.                                 <p><span class="ec-color-grey ec-font-size-2">通常販売価格</span></p>
  267.                                 <p><span class="ec-color-grey ec-font-size-2">
  268.                                     {% if Product.hasProductClass %}
  269.                                     {# 規格を持つ商品の場合の処理 #}
  270.                                         {% if Product.getPrice01Min == Product.getPrice01Max %}
  271.                                             {{ Product.getPrice01IncTaxMin|price }}
  272.                                         {% else %}
  273.                                             {{ Product.Price01IncTaxMin|price }} ~ {{ Product.Price01IncTaxMax|price }}
  274.                                         {% endif %}
  275.                                     {% else %}
  276.                                     {# 規格を持たない商品の場合の処理 #}
  277.                                         {{ Product.getPrice01IncTaxMin|price }}
  278.                                     {% endif %}
  279.                                 </span></p>
  280.                             </a>
  281.                             {% if Product.stock_find %}
  282.                                 {% set form = forms[Product.id] %}
  283.                                 <form name="form{{ Product.id }}" id="productForm{{ Product.id }}" action="{{ url('product_add_cart', {id:Product.id}) }}" method="post">
  284.                                     <div class="ec-productRole__actions">
  285.                                         {% if form.classcategory_id1 is defined %}
  286.                                             <!--<div class="ec-select">
  287.                                                 {{ form_widget(form.classcategory_id1) }}
  288.                                                 {{ form_errors(form.classcategory_id1) }}
  289.                                             </div>-->
  290.                                             {% if form.classcategory_id2 is defined %}
  291.                                                 <!--<div class="ec-select">
  292.                                                     {{ form_widget(form.classcategory_id2) }}
  293.                                                     {{ form_errors(form.classcategory_id2) }}
  294.                                                 </div>-->
  295.                                             {% endif %}
  296.                                         {% endif %}
  297.                                         <!--<div class="ec-numberInput"><span>{{ '数量'|trans }}</span>
  298.                                             {{ form_widget(form.quantity, {'attr': {'class': 'quantity'}}) }}
  299.                                             {{ form_errors(form.quantity) }}
  300.                                         </div>-->
  301.                                     </div>
  302.                                     {{ form_rest(form) }}
  303.                                 </form>
  304.                                 <!--<div class="ec-productRole__btn">
  305.                                     <button type="submit" class="ec-blockBtn--action add-cart" data-cartid="{{ Product.id }}" form="productForm{{ Product.id }}">
  306.                                         {{ 'カートに入れる'|trans }}
  307.                                     </button>
  308.                                 </div>-->
  309.                             {% else %}
  310.                                 <!--<div class="ec-productRole__btn">
  311.                                     <button type="button" class="ec-blockBtn--action" disabled="disabled">
  312.                                         {{ 'ただいま品切れ中です。'|trans }}
  313.                                     </button>
  314.                                 </div>-->
  315.                             {% endif %}
  316.                         </li>
  317.                     {% endfor %}
  318.                 </ul>
  319.             </div>
  320.             <div class="ec-modal">
  321.                 <div class="ec-modal-overlay">
  322.                     <div class="ec-modal-wrap">
  323.                         <span class="ec-modal-close"><span class="ec-icon"><img src="{{ asset('assets/icon/cross-dark.svg') }}" alt=""/></span></span>
  324.                         <div id="ec-modal-header" class="text-center">{{ 'カートに追加しました。'|trans }}</div>
  325.                         <div class="ec-modal-box">
  326.                             <div class="ec-role">
  327.                                 <span class="ec-inlineBtn--cancel">{{ 'お買い物を続ける'|trans }}</span>
  328.                                 <a href="{{ url('cart') }}" class="ec-inlineBtn--action">{{ 'カートへ進む'|trans }}</a>
  329.                             </div>
  330.                         </div>
  331.                     </div>
  332.                 </div>
  333.             </div>
  334.             <div class="ec-pagerRole">
  335.                 {% include "pager.twig" with {'pages': pagination.paginationData} %}
  336.             </div>
  337.         {% endif %}
  338.     {% endif %}
  339. {% endblock %}