app/template/magamar/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 Tags = repository('Eccube\\Entity\\Tag').getList() %}
  11. {% set current_tag = app.request.query.get('tag_id') %}
  12. {% block javascript %}
  13.     <script>
  14.         eccube.productsClassCategories = {
  15.             {% for Product in pagination %}
  16.             "{{ Product.id|escape('js') }}": {{ class_categories_as_json(Product)|raw }}{% if loop.last == false %}, {% endif %}
  17.             {% endfor %}
  18.         };
  19.         $(function() {
  20.             // 表示件数を変更
  21.             $('.disp-number').change(function() {
  22.                 var dispNumber = $(this).val();
  23.                 $('#disp_number').val(dispNumber);
  24.                 $('#pageno').val(1);
  25.                 $("#form1").submit();
  26.             });
  27.             // 並び順を変更
  28.             $('.order-by').change(function() {
  29.                 var orderBy = $(this).val();
  30.                 $('#orderby').val(orderBy);
  31.                 $('#pageno').val(1);
  32.                 $("#form1").submit();
  33.             });
  34.             $('.add-cart').on('click', function(e) {
  35.                 var $form = $(this).parents('li').find('form');
  36.                 // 個数フォームのチェック
  37.                 var $quantity = $form.parent().find('.quantity');
  38.                 if ($quantity.val() < 1) {
  39.                     $quantity[0].setCustomValidity('{{ '1以上で入力してください。'|trans }}');
  40.                     setTimeout(function() {
  41.                         loadingOverlay('hide');
  42.                     }, 100);
  43.                     return true;
  44.                 } else {
  45.                     $quantity[0].setCustomValidity('');
  46.                 }
  47.                 e.preventDefault();
  48.                 $.ajax({
  49.                     url: $form.attr('action'),
  50.                     type: $form.attr('method'),
  51.                     data: $form.serialize(),
  52.                     dataType: 'json',
  53.                     beforeSend: function(xhr, settings) {
  54.                         // Buttonを無効にする
  55.                         $('.add-cart').prop('disabled', true);
  56.                     }
  57.                 }).done(function(data) {
  58.                     // レスポンス内のメッセージをalertで表示
  59.                     $.each(data.messages, function() {
  60.                         $('#ec-modal-header').text(this);
  61.                     });
  62.                     $('.ec-modal').show()
  63.                     // カートブロックを更新する
  64.                     $.ajax({
  65.                         url: '{{ url('block_cart') }}',
  66.                         type: 'GET',
  67.                         dataType: 'html'
  68.                     }).done(function(html) {
  69.                         $('.ec-headerRole__cart').html(html);
  70.                     });
  71.                 }).fail(function(data) {
  72.                     alert('{{  'カゴへの追加に失敗しました。'|trans }}');
  73.                 }).always(function(data) {
  74.                     // Buttonを有効にする
  75.                     $('.add-cart').prop('disabled', false);
  76.                 });
  77.             });
  78.         });
  79.         $('.ec-modal-wrap').on('click', function(e) {
  80.             // モーダル内の処理は外側にバブリングさせない
  81.             e.stopPropagation();
  82.         });
  83.         $('.ec-modal-overlay, .ec-modal, .ec-modal-close, .ec-inlineBtn--cancel').on('click', function() {
  84.             $('.ec-modal').hide()
  85.         });
  86.     </script>
  87. {% endblock %}
  88. {% block main %}
  89.     {% if search_form.category_id.vars.errors|length > 0 %}
  90.         <div class="ec-searchnavRole">
  91.             <p class="errormsg text-danger">{{ 'ご指定のカテゴリは存在しません'|trans }}</p>
  92.         </div>
  93.     {% else %}
  94.         <div class="ec-searchnavRole">
  95.             <form name="form1" id="form1" method="get" action="?">
  96.                 {% for item in search_form %}
  97.                     <input type="hidden" id="{{ item.vars.id }}"
  98.                            name="{{ item.vars.full_name }}"
  99.                            {% if item.vars.value is not empty %}value="{{ item.vars.value }}" {% endif %}/>
  100.                 {% endfor %}
  101.             </form>
  102.             <div class="ec-searchnavRole__topicpath">
  103.                 <ol class="ec-topicpath">
  104.                     {% if Category is not null %}
  105.                         {% for Path in Category.path %}
  106.                             <li class="ec-topicpath__item{% if loop.last %}--active{% endif %}">{{ Path.name }}</li>
  107.                         {% endfor %}
  108.                     {% elseif current_tag is not null %}
  109.                         {% for Tag in Tags %}
  110.                             {% if current_tag == Tag.id %}
  111.                                 <li class="ec-topicpath__item{% if loop.last %}--active{% endif %}">{{ Tag.name }}の商品一覧</li>
  112.                             {% endif %}
  113.                         {% endfor %}
  114.                     {% elseif search_form.vars.value and search_form.vars.value.name %}
  115.                         <li class="ec-topicpath__item">{{ search_form.vars.value.name }}の検索結果</li>
  116.                     {% else %}
  117.                         <li class="ec-topicpath__item">{{ 'すべて'|trans }}</li>
  118.                     {% endif %}
  119.                 </ol>
  120.             </div>
  121.             <div class="ec-searchnavRole__infos">
  122.                 <div class="ec-searchnavRole__counter">
  123.                     {% if pagination.totalItemCount > 0 %}
  124.                         {{ '<span class="ec-font-bold">%count%件</span><span>の商品</span>'|trans({ '%count%': pagination.totalItemCount })|raw }}
  125.                     {% else %}
  126.                         <span>{{ 'お探しの商品は見つかりませんでした'|trans }}</span>
  127.                     {% endif %}
  128.                 </div>
  129.                 {% if pagination.totalItemCount > 0 %}
  130.                     <div class="ec-searchnavRole__actions">
  131.                         <div class="ec-select">
  132.                             {{ form_widget(search_form.disp_number, {'id': '', 'attr': {'class': 'disp-number'}}) }}
  133.                             {{ form_widget(search_form.orderby, {'id': '', 'attr': {'class': 'order-by'}}) }}
  134.                         </div>
  135.                     </div>
  136.                 {% endif %}
  137.             </div>
  138.         </div>
  139.         {# 絵本の一覧は外部サイトへ #}
  140.         {% if search_form.category_id.vars.value == 8 %}
  141.             <div class="block-insert">
  142.                 <a class="external-link" href="https://axel.as-1.co.jp/asone/keyword/?q=絵本" target="_blank" rel="noopener noreferrer">絵本の購入はこちら(アズワンAXELショップへ)</a>
  143.             </div>
  144.         {% endif %}
  145.         {% if pagination.totalItemCount > 0 %}
  146.             <div class="ec-shelfRole">
  147.                 <ul class="ec-shelfGrid">
  148.                     {% for Product in pagination %}
  149.                         <li class="ec-shelfGrid__item">
  150.                             <a href="{{ url('product_detail', {'id': Product.id}) }}">
  151.                                 <div class="ec-shelfGrid__item-image">
  152.                                     <img src="{{ asset(Product.main_list_image|no_image_product, 'save_image') }}" alt="{{ Product.name }}" {% if loop.index > 5 %} loading="lazy"{% endif %}>
  153.                                 </div>
  154.                                 <dl class="ec-shelfGrid__item-detail">
  155.                                     <dt>{{ Product.name }}</dt>
  156.                                     <dd>{{ '発売日:'|trans }}{{ Product.releaseDate }}</dd>
  157.                                     {% if Product.numOfIssues is not empty %}
  158.                                         <dd>{{ '年間発行数:'|trans }}{{ Product.numOfIssues }}</dd>
  159.                                     {% endif %}
  160.                                 </dl>
  161.                                 <p class="price02-default">
  162.                                     {% if Product.hasProductClass %}
  163.                                         {% if Product.getPrice02Min == Product.getPrice02Max %}
  164.                                             {{ Product.getPrice02IncTaxMin|price }}
  165.                                         {% else %}
  166.                                             {% if Product.className1 == '付録' %}
  167.                                                 <span class="class-name">付録なし</span>{{ Product.getPrice02IncTaxMin|price }}<br><span class="class-name">付録あり</span>{{ Product.getPrice02IncTaxMax|price }}
  168.                                             {% endif %}
  169.                                         {% endif %}
  170.                                     {% else %}
  171.                                         {{ Product.getPrice02IncTaxMin|price }}
  172.                                     {% endif %}
  173.                                     <span class="price-tax">
  174.                                     {% if Product.hasProductClass -%}
  175.                                         {{ '(税込み・送料込み)'|trans }}
  176.                                     {% else %}
  177.                                         {% if Product.shippingType == 'inhouse' %}
  178.                                             {{ '(税込み・送料込み)'|trans }}
  179.                                         {% else %}
  180.                                             {{ '(税込み・送料無料)'|trans }}
  181.                                         {% endif %}
  182.                                     {% endif %}
  183.                                     </span>
  184.                                 </p>
  185.                             </a>
  186.                             <div class="ec-productRole__action">
  187.                                 {% if Product.stock_find %}
  188.                                     {% set form = forms[Product.id] %}
  189.                                     <form name="form{{ Product.id }}" id="productForm{{ Product.id }}" action="{{ url('product_add_cart', {id:Product.id}) }}" method="post">
  190.                                         <div class="ec-productRole__actions">
  191.                                             {% if form.classcategory_id1 is defined %}
  192.                                                 <div class="ec-select">
  193.                                                     <span class="ec-formUnit">{{ '付録'|trans }}</span>
  194.                                                     {{ form_widget(form.classcategory_id1) }}
  195.                                                     {{ form_errors(form.classcategory_id1) }}
  196.                                                 </div>
  197.                                                 {% if form.classcategory_id2 is defined %}
  198.                                                     <div class="ec-select">
  199.                                                         <span class="ec-formUnit">{{ '付録'|trans }}</span>
  200.                                                         {{ form_widget(form.classcategory_id2) }}
  201.                                                         {{ form_errors(form.classcategory_id2) }}
  202.                                                     </div>
  203.                                                 {% endif %}
  204.                                             {% endif %}
  205.                                             <div class="ec-numberInput"><span class="ec-formUnit">{{ '数量'|trans }}</span>
  206.                                                 {{ form_widget(form.quantity, {'attr': {'class': 'quantity'}}) }}
  207.                                                 {{ form_errors(form.quantity) }}
  208.                                             </div>
  209.                                         </div>
  210.                                         {{ form_rest(form) }}
  211.                                     </form>
  212.                                     <div class="ec-productRole__btn">
  213.                                         <button type="submit" class="ec-blockBtn--action add-cart" data-cartid="{{ Product.id }}" form="productForm{{ Product.id }}">
  214.                                             {{ 'カゴに入れる'|trans }}
  215.                                         </button>
  216.                                     </div>
  217.                                 {% else %}
  218.                                     <div class="ec-productRole__btn">
  219.                                         <button type="button" class="ec-blockBtn--action" disabled="disabled">
  220.                                             {{ 'ただいま品切れ中です。'|trans }}
  221.                                         </button>
  222.                                     </div>
  223.                                 {% endif %}
  224.                             </div>
  225.                         </li>
  226.                     {% endfor %}
  227.                 </ul>
  228.             </div>
  229.             <div class="ec-modal">
  230.                 <div class="ec-modal-overlay">
  231.                     <div class="ec-modal-wrap">
  232.                         <span class="ec-modal-close"><span class="ec-icon"><img src="{{ asset('assets/icon/cross-dark.svg') }}" alt=""/></span></span>
  233.                         <div id="ec-modal-header" class="text-center">{{ 'カゴに追加しました。'|trans }}</div>
  234.                         <div class="ec-modal-box">
  235.                             <div class="ec-role">
  236.                                 <span class="ec-inlineBtn--cancel">{{ 'お買い物を続ける'|trans }}</span>
  237.                                 <a href="{{ url('cart') }}" class="ec-inlineBtn--action">{{ '注文へ進む'|trans }}</a>
  238.                             </div>
  239.                         </div>
  240.                     </div>
  241.                 </div>
  242.             </div>
  243.             <div class="ec-pagerRole">
  244.                 {% include "pager.twig" with {'pages': pagination.paginationData} %}
  245.             </div>
  246.         {% endif %}
  247.     {% endif %}
  248. {% endblock %}