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 stylesheet %}
  87. <style>
  88. #page_product_list .ec-shelfRole#products-area .ec-shelfGrid .ec-shelfGrid__item{
  89.     justify-content: space-between;
  90. }
  91. #page_product_list .ec-shelfRole#products-area .ec-shelfGrid .ec-shelfGrid__item > a{
  92.     display: flex;
  93.     height: 100%;
  94. }
  95. @media only screen and (min-width: 768px){
  96. #page_product_list .ec-shelfRole#products-area .ec-shelfGrid .ec-shelfGrid__item > a > div{
  97.     flex-direction: column;
  98. }
  99. }
  100. .product-ttlarea{
  101.     display: flex;
  102.     flex-direction: column;
  103.     justify-content: space-between;
  104.     flex: auto;
  105. }
  106. .listphoto{
  107.     display: flex;
  108.     flex: 1;
  109.     aspect-ratio: 218 / 309.67;
  110. }
  111. .product-ttl{
  112.     margin-top: 0;
  113. }
  114. </style>
  115. {% endblock stylesheet %}
  116. {% block main %}
  117.     {% if search_form.category_id.vars.errors|length > 0 %}
  118.         <div class="ec-searchnavRole">
  119.             <p class="errormsg text-danger">{{ 'ご指定のカテゴリは存在しません'|trans }}</p>
  120.         </div>
  121.     {% else %}
  122.         <div class="ec-searchnavRole">
  123.             <form name="form1" id="form1" method="get" action="?">
  124.                 {% for item in search_form %}
  125.                     <input type="hidden" id="{{ item.vars.id }}"
  126.                            name="{{ item.vars.full_name }}"
  127.                            {% if item.vars.value is not empty %}value="{{ item.vars.value }}" {% endif %}/>
  128.                 {% endfor %}
  129.             </form>
  130.             <!--★タイトル★-->
  131.             <h2 class="title">
  132.                 {% if search_form.vars.value and search_form.vars.value.name %}
  133.                 {% set subtitle = "書籍検索結果" %}
  134.                 {% endif %}
  135.                 {{ subtitle }}
  136.             </h2>
  137.             <!--▼検索条件-->
  138.             {% if search_form.vars.value and search_form.vars.value.name %}
  139.             <ul class="pagecond_area">
  140.                 <li><strong>検索キーワード:</strong>{{ search_form.vars.value.name }}</li>
  141.             </ul>
  142.             {% endif %}
  143.             <!--
  144.             <div class="ec-searchnavRole__topicpath">
  145.                 <ol class="ec-topicpath">
  146.                     <li class="ec-topicpath__item"><a href="{{ url('product_list') }}">{{ '全て'|trans }}</a>
  147.                     </li>
  148.                     {% if Category is not null %}
  149.                         {% for Path in Category.path %}
  150.                             <li class="ec-topicpath__divider">|</li>
  151.                             <li class="ec-topicpath__item{% if loop.last %}--active{% endif %}"><a
  152.                                         href="{{ url('product_list') }}?category_id={{ Path.id }}">{{ Path.name }}</a>
  153.                             </li>
  154.                         {% endfor %}
  155.                     {% endif %}
  156.                     {% if search_form.vars.value and search_form.vars.value.name %}
  157.                         <li class="ec-topicpath__divider">|</li>
  158.                         <li class="ec-topicpath__item">{{ '「%name%」の検索結果'|trans({ '%name%': search_form.vars.value.name }) }}</li>
  159.                     {% endif %}
  160.                 </ol>
  161.             </div>
  162.             -->
  163.             <div class="ec-searchnavRole__infos pagenumber_area">
  164.                 <div class="pagination-area flex">
  165.                     <div class="ec-searchnavRole__counter">
  166.                         {% if pagination.totalItemCount > 0 %}
  167.                             {{ '<span class="ec-font-bold attention">%count%件</span><span>の商品がございます。</span>'|trans({ '%count%': pagination.totalItemCount })|raw }}
  168.                         {% else %}
  169.                             <span>{{ 'お探しの商品は見つかりませんでした'|trans }}</span>
  170.                         {% endif %}
  171.                     </div>
  172.                     {% if pagination.totalItemCount > 0 %}
  173.                     <div class="ec-searchnavRole__actions">
  174.                         <div class="ec-select">
  175.                             {{ form_widget(search_form.disp_number, {'id': '', 'attr': {'class': 'disp-number'}}) }}
  176.                             {{ form_widget(search_form.orderby, {'id': '', 'attr': {'class': 'order-by'}}) }}
  177.                         </div>
  178.                     </div>
  179.                     {% endif %}
  180.                 </div>
  181.             </div>
  182.         </div>
  183.         {% if pagination.totalItemCount > 0 %}
  184.             <div class="ec-shelfRole" id="products-area">
  185.                 <ul class="ec-shelfGrid">
  186.                     {% for Product in pagination %}
  187.                         <li class="ec-shelfGrid__item">
  188.                             <a href="{{ url('product_detail', {'id': Product.id}) }}">
  189.                                 <div class="product-detailarea flex">
  190.                                     <div class="listphoto">
  191.                                         <div class="listphotoarea">
  192.                                             <p class="ec-shelfGrid__item-image">
  193.                                                 <img src="{{ asset(Product.main_list_image|no_image_product, 'save_image') }}" alt="{{ Product.name }}" {% if loop.index > 5 %} loading="lazy"{% endif %}>
  194.                                             </p>
  195.                                         </div>
  196.                                     </div>
  197.                                     <div class="product-ttlarea">
  198.                                         {# タグ
  199.                                         {% if Product.Tags is not null %}
  200.                                             {% for Tag in Product.Tags %}
  201.                                                 {% if Tag.id == '1' %}
  202.                                                 <ul class="ec-productRole__tags flex">
  203.                                                     <li class="ec-productRole__tag tag_{{ Tag.id }}">{{ Tag }}</li>
  204.                                                 </ul>
  205.                                                 {% endif %}
  206.                                             {% endfor %}
  207.                                         {% endif %}
  208.                                         #}
  209.                                         <!-- 書籍タイトル -->
  210.                                         <div class="product-ttl">
  211.                                         {% if Product.sub_name_up %}
  212.                                             <p>{{ Product.sub_name_up }}</p>
  213.                                         {% endif %}
  214.                                         <h3>{{ Product.name }}</h3>
  215.                                         {% if Product.sub_name_down %}
  216.                                             <p>{{ Product.sub_name_down }}</p>
  217.                                         {% endif %}
  218.                                         </div>
  219.                                         <!-- 価格 -->
  220.                                         <div class="productlist-pricebox">
  221.                                             <p class="price02-default">
  222.                                                 定価:
  223.                                                 <span class="price sale_price">
  224.                                                 {% if Product.hasProductClass %}
  225.                                                     {% if Product.getPrice02Min == Product.getPrice02Max %}
  226.                                                         {{ Product.getPrice02IncTaxMin|number_format }}
  227.                                                     {% else %}
  228.                                                         {{ Product.getPrice02IncTaxMin|number_format }} ~ {{ Product.getPrice02IncTaxMax|number_format }}
  229.                                                     {% endif %}
  230.                                                 {% else %}
  231.                                                     {{ Product.getPrice02IncTaxMin|number_format }}
  232.                                                 {% endif %}
  233.                                                 円</span>
  234.                                                 (税込)
  235.                                             </p>
  236.                                         </div>
  237.                                     </div>
  238.                                 </div>
  239.                             </a>
  240.                             <!-- 買い物かご -->
  241.                             <div class="productlist-cartarea only-pc">
  242.                                  <!--★商品詳細を見る★-->
  243.                                 <div class="detail_btn">
  244.                                     <a class="rgreen-btn__s" href="{{ url('product_detail', {'id': Product.id}) }}">
  245.                                         商品詳細を見る
  246.                                     </a>
  247.                                 </div>
  248.                             {% if Product.stock_find %}
  249.                                 {% set form = forms[Product.id] %}
  250.                                 <form name="form{{ Product.id }}" id="productForm{{ Product.id }}" action="{{ url('product_add_cart', {id:Product.id}) }}" method="post">
  251.                                     <div class="ec-productRole__actions">
  252.                                         {% if form.classcategory_id1 is defined %}
  253.                                         <div class="classlist">
  254.                                             <div class="ec-select">
  255.                                                 {{form.classcategory_id1.vars.label }}:
  256.                                                 {{ form_widget(form.classcategory_id1) }}
  257.                                                 {{ form_errors(form.classcategory_id1) }}
  258.                                             </div>
  259.                                             {% if form.classcategory_id2 is defined %}
  260.                                                 <div class="ec-select">
  261.                                                     {{form.classcategory_id2.vars.label }}:
  262.                                                     {{ form_widget(form.classcategory_id2) }}
  263.                                                     {{ form_errors(form.classcategory_id2) }}
  264.                                                 </div>
  265.                                             {% endif %}
  266.                                         </div>
  267.                                         {% endif %}
  268.                                         <div class="ec-numberInput"><span>数量:</span>
  269.                                             {{ form_widget(form.quantity, {'attr': {'class': 'quantity'}}) }}
  270.                                             {{ form_errors(form.quantity) }}
  271.                                         </div>
  272.                                     </div>
  273.                                     {{ form_rest(form) }}
  274.                                 </form>
  275.                                 <div class="ec-productRole__btn">
  276.                                     <button type="submit" class="ec-blockBtn--action add-cart orange-btn__s" data-cartid="{{ Product.id }}" form="productForm{{ Product.id }}">
  277.                                         カゴに入れる
  278.                                     </button>
  279.                                 </div>
  280.                             {% else %}
  281.                                 <div class="attention">
  282.                                     {% set targettag = [] %}
  283.                                     {% for tag in Product.Tags %}
  284.                                         {% set targettag = targettag|merge([tag.id]) %}
  285.                                     {% endfor %}
  286.                                     {% if '7' in targettag %}
  287.                                     申し訳ございませんが、本商品は絶版となりました。
  288.                                     {% elseif '5' in targettag %}
  289.                                     この商品は発売前のため購入いただけません。
  290.                                     {% else %}
  291.                                     申し訳ございませんが、本商品は只今品切れ中です。
  292.                                     {% endif %}
  293.                                 </div>
  294.                             {% endif %}
  295.                             </div>
  296.                         </li>
  297.                     {% endfor %}
  298.                 </ul>
  299.             </div>
  300.             <div class="ec-modal">
  301.                 <div class="ec-modal-overlay">
  302.                     <div class="ec-modal-wrap">
  303.                         <span class="ec-modal-close"><span class="ec-icon"><img src="{{ asset('assets/icon/cross-dark.svg') }}" alt=""/></span></span>
  304.                         <div id="ec-modal-header" class="text-center">{{ 'カートに追加しました。'|trans }}</div>
  305.                         <div class="ec-modal-box">
  306.                             <div class="ec-role">
  307.                                 <span class="ec-inlineBtn--cancel">{{ 'お買い物を続ける'|trans }}</span>
  308.                                 <a href="{{ url('cart') }}" class="ec-inlineBtn--action">{{ 'カートへ進む'|trans }}</a>
  309.                             </div>
  310.                         </div>
  311.                     </div>
  312.                 </div>
  313.             </div>
  314.             {% if pagination.totalItemCount > 0 %}
  315.             <div class="ec-pagerRole">
  316.                 {% include "pager.twig" with {'pages': pagination.paginationData} %}
  317.             </div>
  318.             {% endif %}
  319.         {% endif %}
  320.     {% endif %}
  321. {% endblock %}