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 main_class = 'l-main l-main--products' %}
  11. {% block javascript %}
  12.     <script>
  13.         eccube.productsClassCategories = {
  14.             {% for Product in pagination %}
  15.             "{{ Product.id|escape('js') }}": {{ class_categories_as_json(Product)|raw }}{% if loop.last == false %}, {% endif %}
  16.             {% endfor %}
  17.         };
  18.         $(function() {
  19.             // 表示件数を変更
  20.             $('.disp-number').change(function() {
  21.                 var dispNumber = $(this).val();
  22.                 $('#disp_number').val(dispNumber);
  23.                 $('#pageno').val(1);
  24.                 $("#form1").submit();
  25.             });
  26.             // 並び順を変更
  27.             $('.order-by').change(function() {
  28.                 var orderBy = $(this).val();
  29.                 $('#orderby').val(orderBy);
  30.                 $('#pageno').val(1);
  31.                 $("#form1").submit();
  32.             });
  33.             $('.add-cart').on('click', function(e) {
  34.                 var $form = $(this).parents('li').find('form');
  35.                 // 個数フォームのチェック
  36.                 var $quantity = $form.parent().find('.quantity');
  37.                 if ($quantity.val() < 1) {
  38.                     $quantity[0].setCustomValidity('{{ '1以上で入力してください。'|trans }}');
  39.                     setTimeout(function() {
  40.                         loadingOverlay('hide');
  41.                     }, 100);
  42.                     return true;
  43.                 } else {
  44.                     $quantity[0].setCustomValidity('');
  45.                 }
  46.                 e.preventDefault();
  47.                 $.ajax({
  48.                     url: $form.attr('action'),
  49.                     type: $form.attr('method'),
  50.                     data: $form.serialize(),
  51.                     dataType: 'json',
  52.                     beforeSend: function(xhr, settings) {
  53.                         // Buttonを無効にする
  54.                         $('.add-cart').prop('disabled', true);
  55.                     }
  56.                 }).done(function(data) {
  57.                     // レスポンス内のメッセージをalertで表示
  58.                     $.each(data.messages, function() {
  59.                         $('#ec-modal-header').html(this);
  60.                     });
  61.                     $('.ec-modal').show()
  62.                     // カートブロックを更新する
  63.                     $.ajax({
  64.                         url: '{{ url('block_cart') }}',
  65.                         type: 'GET',
  66.                         dataType: 'html'
  67.                     }).done(function(html) {
  68.                         $('.ec-headerRole__cart').html(html);
  69.                     });
  70.                 }).fail(function(data) {
  71.                     alert('{{ 'カートへの追加に失敗しました。'|trans }}');
  72.                 }).always(function(data) {
  73.                     // Buttonを有効にする
  74.                     $('.add-cart').prop('disabled', false);
  75.                 });
  76.             });
  77.         });
  78.         $('.ec-modal-wrap').on('click', function(e) {
  79.             // モーダル内の処理は外側にバブリングさせない
  80.             e.stopPropagation();
  81.         });
  82.         $('.ec-modal-overlay, .ec-modal, .ec-modal-close, .ec-inlineBtn--cancel').on('click', function() {
  83.             $('.ec-modal').hide()
  84.         });
  85.     </script>
  86. {% endblock %}
  87. {% block main %}
  88.     <div class="l-page-heading">
  89.         <ul class="c-breadcrumb">
  90.             <li class="c-breadcrumb__item"><a href="{{ url('homepage') }}" class="c-breadcrumb__link c-btn-txt">TOP</a></li>
  91.             <li class="c-breadcrumb__item"><span class="c-breadcrumb__txt">商品リスト</span></li>
  92.         </ul>
  93.         <h1 class="l-page-heading__ttl">
  94.             <span class="l-page-heading__ttl-jp">商品リスト</span>
  95.             <span class="l-page-heading__ttl-en">PRODUCTS</span>
  96.         </h1>
  97.     </div>
  98.     {% if search_form.category_id.vars.errors|length > 0 %}
  99.         <div class="ec-searchnavRole">
  100.             <p class="errormsg text-danger">{{ 'ご指定のカテゴリは存在しません'|trans }}</p>
  101.         </div>
  102.     {% else %}
  103.         <div class="ec-searchnavRole">
  104.             <form name="form1" id="form1" method="get" action="?">
  105.                 {% for item in search_form %}
  106.                     <input type="hidden" id="{{ item.vars.id }}"
  107.                            name="{{ item.vars.full_name }}"
  108.                            {% if item.vars.value is not empty %}value="{{ item.vars.value }}" {% endif %}/>
  109.                 {% endfor %}
  110.             </form>
  111.             {% if Category is null or Category is not null and Category.id != '11' %}
  112.                 <ul class="p-products-cat">
  113.                     <li class="p-products-cat__item{% if Category is null %} current{% endif %}">
  114.                         <a href="{{ url('product_list') }}" class="p-products-cat__link">
  115.                             <span class="p-products-cat__large">すべて</span>
  116.                             <span class="p-products-cat__small">(ALL)</span>
  117.                         </a>
  118.                     </li>
  119.                     <li class="p-products-cat__item{% if Category is not null and Category.id == '8' %} current{% endif %}">
  120.                         <a href="{{ url('product_list') }}?category_id=8" class="p-products-cat__link">
  121.                             <span class="p-products-cat__large">MUYU-SEN Nature.</span>
  122.                             <span class="p-products-cat__small">(むゆうせんナチュレ)</span>
  123.                         </a>
  124.                     </li>
  125.                     <li class="p-products-cat__item{% if Category is not null and Category.id == '9' or Category is not null and Category.id == '13' or Category is not null and Category.id == '14' or Category is not null and Category.id == '15' %} current{% endif %}">
  126.                         <a href="{{ url('product_list') }}?category_id=9" class="p-products-cat__link">
  127.                             <span class="p-products-cat__large">Nature.Dog</span>
  128.                             <span class="p-products-cat__small">(ナチュレドッグ)</span>
  129.                         </a>
  130.                     </li>
  131.                     {% set group1 = repository("Plugin\\CustomerGroup42\\Entity\\Group").find(1) %}
  132.                     {% set group2 = repository("Plugin\\CustomerGroup42\\Entity\\Group").find(2) %}
  133.                     {% set group3 = repository("Plugin\\CustomerGroup42\\Entity\\Group").find(3) %}
  134.                     {% set group4 = repository("Plugin\\CustomerGroup42\\Entity\\Group").find(4) %}
  135.                     {% if group1 is not null and is_granted('view', group1) or group2 is not null and is_granted('view', group2) or group3 is not null and is_granted('view', group3) or group4 is not null and is_granted('view', group4) %}
  136.                         <li class="p-products-cat__item{% if Category is not null %}{% if Category.id == '10' %} current{% endif %}{% endif %}">
  137.                             <a href="{{ url('product_list') }}?category_id=10" class="p-products-cat__link">
  138.                                 <span class="p-products-cat__large">Heat therapy Member</span>
  139.                                 <span class="p-products-cat__small">(ヒートセラピー会員専⽤)</span>
  140.                             </a>
  141.                         </li>
  142.                     {% endif %}
  143.                 </ul>
  144.                 {% if Category is not null and Category.id == '9' or Category is not null and Category.id == '13' or Category is not null and Category.id == '14' or Category is not null and Category.id == '15' %}
  145.                     <ul class="p-products-cat p-products-cat--child">
  146.                         <li class="p-products-cat__item{% if Category is not null and Category.id == '13' %} current{% endif %}">
  147.                             <a href="{{ url('product_list') }}?category_id=13" class="p-products-cat__link">
  148.                                 <span class="p-products-cat__small">ワンコケア用品</span>
  149.                             </a>
  150.                         </li>
  151.                         <li class="p-products-cat__item{% if Category is not null and Category.id == '14' %} current{% endif %}">
  152.                             <a href="{{ url('product_list') }}?category_id=14" class="p-products-cat__link">
  153.                                 <span class="p-products-cat__small">ワンコのおやつとご飯</span>
  154.                             </a>
  155.                         </li>
  156.                         <li class="p-products-cat__item{% if Category is not null and Category.id == '15' %} current{% endif %}">
  157.                             <a href="{{ url('product_list') }}?category_id=15" class="p-products-cat__link">
  158.                                 <span class="p-products-cat__small">ワンコのグッズ</span>
  159.                             </a>
  160.                         </li>
  161.                     </ul>
  162.                 {% endif %}
  163.             {% endif %}
  164.             <div class="ec-searchnavRole__infos p-products-infos">
  165.                 {% if pagination.totalItemCount > 0 %}
  166.                     <div class="ec-searchnavRole__actions p-products-infos__actions">
  167.                         {{ form_widget(search_form.disp_number, {'id': '', 'attr': {'class': 'disp-number p-products-infos__select'}}) }}
  168.                         {{ form_widget(search_form.orderby, {'id': '', 'attr': {'class': 'order-by p-products-infos__select'}}) }}
  169.                     </div>
  170.                 {% else %}
  171.                     <p class="p-products-infos__none">{{ 'お探しの商品は見つかりませんでした'|trans }}</p>
  172.                 {% endif %}
  173.             </div>
  174.         </div>
  175.         {% if pagination.totalItemCount > 0 %}
  176.             <div class="ec-shelfRole">
  177.                 <ul class="ec-shelfGrid p-products-list">
  178.                     {% for Product in pagination %}
  179.                         <li class="ec-shelfGrid__item p-products-list__item">
  180.                             {# お気に入り #}
  181.                             {% if is_granted('ROLE_USER') %}{# ログインしている場合 #}
  182.                                 {{ include('Block/product_list_favorite_block.twig') }}
  183.                             {% endif %}
  184.                             <a href="{{ url('product_detail', {'id': Product.id}) }}" class=" p-products-list__link">
  185.                                 {# タグと「定期便対応」カテゴリを出力 ここから #}
  186.                                 {% if Product.ProductCategories is not empty %}
  187.                                     {% if Product.Tags is not empty %}
  188.                                         <ul class="c-tags p-products-list__tags">
  189.                                             {% for Tag in Product.Tags %}
  190.                                                 <li class="c-tags__tag p-products-list__tags-tag tag_{{ Tag.id }}">{{ Tag }}</li>
  191.                                             {% endfor %}
  192.                                             {% for ProductCategory in Product.ProductCategories %}
  193.                                                 {% if ProductCategory.Category.path[0].id == '11' %}
  194.                                                     {% for Category in ProductCategory.Category.path %}
  195.                                                         <li class="c-tags__tag p-products-list__tags-tag tag_cat{{ Category.id }}">{{ Category.name }}</li>
  196.                                                     {% endfor %}
  197.                                                 {% endif %}
  198.                                             {% endfor %}
  199.                                         </ul>
  200.                                     {% elseif Product.Tags is empty %}
  201.                                         {% for ProductCategory in Product.ProductCategories %}
  202.                                             {% if ProductCategory.Category.path[0].id == '11' %}
  203.                                                 <ul class="c-tags p-products-list__tags">
  204.                                                     {% for Category in ProductCategory.Category.path %}
  205.                                                         <li class="c-tags__tag p-products-list__tags-tag tag_cat{{ Category.id }}">{{ Category.name }}</li>
  206.                                                     {% endfor %}
  207.                                                 </ul>
  208.                                             {% endif %}
  209.                                         {% endfor %}
  210.                                     {% endif %}
  211.                                 {% elseif Product.ProductCategories is empty and Product.Tags is not empty %}
  212.                                     <ul class="c-tags p-products-list__tags">
  213.                                         {% for Tag in Product.Tags %}
  214.                                             <li class="c-tags__tag p-products-list__tags-tag tag_{{ Tag.id }}">{{ Tag }}</li>
  215.                                         {% endfor %}
  216.                                     </ul>
  217.                                 {% endif %}
  218.                                 {# タグと「定期便対応」カテゴリを出力 ここまで #}
  219.                                 {# 「定期便対応」以外のカテゴリを出力 ここから #}
  220.                                 {% if Product.ProductCategories is not empty %}
  221.                                     {% for ProductCategory in Product.ProductCategories %}
  222.                                         {% if ProductCategory.Category.path[0].id != '11' %}
  223.                                             <ul class="c-cats p-products-list__cats">
  224.                                                 <li class="c-cats__cat p-products-list__cats-cat">
  225.                                                     {% for Category in ProductCategory.Category.path %}
  226.                                                         <span class="c-cats__cat-txt">{{ Category.name }}</span>{%- if loop.last == false %}
  227.                                                             <span class="c-cats__cat-arrow">></span>{% endif -%}
  228.                                                     {% endfor %}
  229.                                                 </li>
  230.                                             </ul>
  231.                                         {% endif %}
  232.                                     {% endfor %}
  233.                                 {% endif %}
  234.                                 {# 「定期便対応」以外のカテゴリを出力 ここまで #}
  235.                                 <p class="ec-shelfGrid__item-image p-products-list__img-wrap">
  236.                                     <img src="{{ asset(Product.main_list_image|no_image_product, 'save_image') }}" alt="{{ Product.name }}" {% if loop.index > 5 %} loading="lazy"{% endif %}>
  237.                                 </p>
  238.                                 <p class=" p-products-list__name">{{ Product.name }}</p>
  239.                                 <div class="p-products-list__info">
  240.                                     {% if Product.production_capacity is not empty %}
  241.                                         <p class=" p-products-list__capacity">{{ Product.production_capacity }}</p>
  242.                                     {% endif %}
  243.                                     <p class="price02-default p-products-list__price">
  244.                                         {% if Product.hasProductClass %}
  245.                                             {% if Product.getPrice02Min == Product.getPrice02Max %}
  246.                                                 {{ Product.getPrice02IncTaxMin|number_format }}
  247.                                             {% else %}
  248.                                                 {{ Product.getPrice02IncTaxMin|number_format }} ~ {{ Product.getPrice02IncTaxMax|number_format }}
  249.                                             {% endif %}
  250.                                         {% else %}
  251.                                             {{ Product.getPrice02IncTaxMin|number_format }}
  252.                                         {% endif %}円(税込)
  253.                                     </p>
  254.                                 </div>
  255.                             </a>
  256.                         </li>
  257.                     {% endfor %}
  258.                 </ul>
  259.             </div>
  260.             <div class="ec-pagerRole l-pagination">
  261.                 {% include "pager.twig" with {'pages': pagination.paginationData} %}
  262.             </div>
  263.         {% endif %}
  264.     {% endif %}
  265. {% endblock %}