app/template/yamaria/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').html(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-overlay, .ec-modal .ec-inlineBtn--cancel').on('click', function() {
  78.             $('.ec-modal').hide()
  79.         });
  80.     </script>
  81. {% endblock %}
  82. {% block main %}
  83. <div class="ym-topicpath">
  84.     <ul>
  85.         <li><a href="{{ url('homepage') }}">HOME</a></li>
  86.         <li class="ec-topicpath__item"><a href="{{ url('product_list') }}">{{ '全て'|trans }}</a>
  87.         </li>
  88.         {% if Category is not null %}
  89.             {% for Path in Category.path %}
  90.                 <li class="ec-topicpath__item{% if loop.last %}--active{% endif %}"><a
  91.                             href="{{ url('product_list') }}?category_id={{ Path.id }}">{{ Path.name }}</a>
  92.                 </li>
  93.             {% endfor %}
  94.         {% elseif search_form.vars.value and search_form.vars.value.name %}
  95.             <li class="ec-topicpath__item--active"><span>{{ '「%name%」の検索結果'|trans({ '%name%': search_form.vars.value.name }) }}</span>
  96.             </li>
  97.         {% endif %}
  98.     </ul>
  99. </div>
  100. <div class="ym-category_header ym-role">
  101.     <div class="ym-category_title">
  102.         {% if Category is not null %}
  103.         <span class="ym-category_title__main">{{Category}}</span>
  104.         <span class="ym-category_title__sub">商品一覧</span>
  105.         {% elseif search_form.vars.value and search_form.vars.value.name %}
  106.         <span class="ym-category_title__main">{{ '%name%'|trans({ '%name%': search_form.vars.value.name }) }}</span>
  107.         <span class="ym-category_title__sub">の検索結果</span>
  108.         {% else %}
  109.         <span class="ym-category_title__main">すべての商品一覧</span>
  110.         {% endif %}
  111.     </div>
  112.     <p class="ym-category_desc">表示価格は全て税込み価格となります。</p>
  113. </div>
  114.     {% if search_form.category_id.vars.errors|length > 0 %}
  115.         <div class="ec-searchnavRole">
  116.             <p class="errormsg text-danger">{{ 'ご指定のカテゴリは存在しません'|trans }}</p>
  117.         </div>
  118.     {% else %}
  119.         <div class="ec-searchnavRole">
  120.             <form name="form1" id="form1" method="get" action="?">
  121.                 {% for item in search_form %}
  122.                     <input type="hidden" id="{{ item.vars.id }}"
  123.                            name="{{ item.vars.full_name }}"
  124.                            {% if item.vars.value is not empty %}value="{{ item.vars.value }}" {% endif %}/>
  125.                 {% endfor %}
  126.             </form>
  127.             {#
  128.             <div class="ec-searchnavRole__topicpath">
  129.                 <ol>
  130.                     
  131.                     {% if search_form.vars.value and search_form.vars.value.name %}
  132.                         <li class="ec-topicpath__divider">|</li>
  133.                         <li class="ec-topicpath__item">{{ '「%name%」の検索結果'|trans({ '%name%': search_form.vars.value.name }) }}</li>
  134.                     {% endif %}
  135.                 </ol>
  136.             </div>
  137.             #}
  138.             <div class="ec-searchnavRole__infos">
  139.                 <div class="ec-searchnavRole__counter">
  140.                     {% if pagination.totalItemCount > 0 %}
  141.                     {#
  142.                         {{ '<span class="ec-font-bold">%count%件</span><span>の商品が見つかりました</span>'|trans({ '%count%': pagination.totalItemCount })|raw }}
  143.                     #}
  144.                     {% else %}
  145.                         <span>{{ 'お探しの商品は見つかりませんでした'|trans }}</span>
  146.                     {% endif %}
  147.                 </div>
  148.                 {#
  149.                 {% if pagination.totalItemCount > 0 %}
  150.                     <div class="ec-searchnavRole__actions">
  151.                         <div class="ec-select">
  152.                             {{ form_widget(disp_number_form, {'id': '', 'attr': {'class': 'disp-number'}}) }}
  153.                             {{ form_widget(order_by_form, {'id': '', 'attr': {'class': 'order-by'}}) }}
  154.                         </div>
  155.                     </div>
  156.                 {% endif %}
  157.                 #}
  158.             </div>
  159.         </div>
  160.         {% if pagination.totalItemCount > 0 %}
  161.             <div class="ec-shelfRole ym-role">
  162.                 {% if pagination.totalItemCount > 0 %}
  163.                 <div class="ym-list_header">
  164.                     <p>{{ '<span class="ec-font-bold">%count%件</span><span>の商品が見つかりました</span>'|trans({ '%count%': pagination.totalItemCount })|raw }}</p>
  165.                 </div>
  166.                 {% endif %}
  167.                 <ul class="ec-shelfGrid">
  168.                     {% for Product in pagination %}
  169.                         <li class="ec-shelfGrid__item ym-item">
  170.                             <a href="{{ url('product_detail', {'id': Product.id}) }}">
  171.                                 <p class="ec-shelfGrid__item-image ym-item__image">
  172.                                     {% set tag_lb,tag_lt = '','' %}
  173.                                     {% for Tag in Product.Tags %}
  174.                                         {% if Tag.id == 3 %}
  175.                                             {% set tag_lb %}<span class="list_tag tag_pos_lb tag_style_{{ Tag.id }}"><span class="tag_inner">{{ Tag }}</span></span>{% endset %}
  176.                                         {% else %}
  177.                                             {% set tag_lt %}<span class="list_tag tag_pos_lt tag_style_{{ Tag.id }}"><span class="tag_inner">{{ Tag }}</span></span>{% endset %}
  178.                                         {% endif %}
  179.                                     {% endfor %}
  180.                                     {{ tag_lb }}{{ tag_lt }}
  181.                                     <img src="{{ asset(Product.main_list_image|no_image_product, 'save_image') }}">
  182.                                 </p>
  183.                                 <p class="ym-item__name">{{ Product.name }}</p>
  184.                                 {% if Product.description_list %}
  185.                                     <p>{{ Product.description_list|raw|nl2br }}</p>
  186.                                 {% endif %}
  187.                                 <p class="price02-default ym-item__price">
  188.                                     {% if Product.hasProductClass %}
  189.                                         {% if Product.getPrice02Min == Product.getPrice02Max %}
  190.                                             {{ Product.getPrice02IncTaxMin|price }}
  191.                                         {% else %}
  192.                                             {{ Product.getPrice02IncTaxMin|price }} ~ {{ Product.getPrice02IncTaxMax|price }}
  193.                                         {% endif %}
  194.                                     {% else %}
  195.                                         {{ Product.getPrice02IncTaxMin|price }}
  196.                                     {% endif %}
  197.                                 </p>
  198.                             </a>
  199.                             {% if Product.stock_find %}
  200.                                 {% set form = forms[Product.id] %}
  201.                                 {#
  202.                                 <form name="form{{ Product.id }}" id="productForm{{ Product.id }}" action="{{ url('product_add_cart', {id:Product.id}) }}" method="post">
  203.                                     <div class="ec-productRole__actions">
  204.                                         {% if form.classcategory_id1 is defined %}
  205.                                             <div class="ec-select">
  206.                                                 {{ form_widget(form.classcategory_id1) }}
  207.                                                 {{ form_errors(form.classcategory_id1) }}
  208.                                             </div>
  209.                                             {% if form.classcategory_id2 is defined %}
  210.                                                 <div class="ec-select">
  211.                                                     {{ form_widget(form.classcategory_id2) }}
  212.                                                     {{ form_errors(form.classcategory_id2) }}
  213.                                                 </div>
  214.                                             {% endif %}
  215.                                         {% endif %}
  216.                                         <div class="ec-numberInput"><span>{{ '数量'|trans }}</span>
  217.                                             {{ form_widget(form.quantity, {'attr': {'class': 'quantity'}}) }}
  218.                                             {{ form_errors(form.quantity) }}
  219.                                         </div>
  220.                                     </div>
  221.                                     {{ form_rest(form) }}
  222.                                 </form>
  223.                                 
  224.                                 <div class="ec-productRole__btn">
  225.                                     <button type="submit" class="ec-blockBtn--action add-cart" data-cartid="{{ Product.id }}" form="productForm{{ Product.id }}">
  226.                                         {{ 'カートに入れる'|trans }}
  227.                                     </button>
  228.                                 </div>
  229.                                 #}
  230.                             {% else %}
  231.                                 {#
  232.                                 <div class="ec-productRole__btn">
  233.                                     <button type="button" class="ec-blockBtn--action" disabled="disabled">
  234.                                         {{ 'ただいま品切れ中です。'|trans }}
  235.                                     </button>
  236.                                 </div>
  237.                                 #}
  238.                             {% endif %}
  239.                         </li>
  240.                     {% endfor %}
  241.                 </ul>
  242.             </div>
  243.             <div class="ec-modal">
  244.                 <div class="ec-modal-overlay">
  245.                     <div class="ec-modal-wrap">
  246.                         <span class="ec-modal-close"><span class="ec-icon"><img src="{{ asset('assets/icon/cross-dark.svg') }}" alt=""/></span></span>
  247.                         <div id="ec-modal-header" class="text-center">{{ 'カートに追加しました。'|trans }}</div>
  248.                         <div class="ec-modal-box">
  249.                             <div class="ec-role">
  250.                                 <span class="ec-inlineBtn--cancel">{{ 'お買い物を続ける'|trans }}</span>
  251.                                 <a href="{{ url('cart') }}" class="ec-inlineBtn--action">{{ 'カートへ進む'|trans }}</a>
  252.                             </div>
  253.                         </div>
  254.                     </div>
  255.                 </div>
  256.             </div>
  257.             <div class="ec-pagerRole">
  258.                 {% include "pager.twig" with {'pages': pagination.paginationData} %}
  259.             </div>
  260.         {% endif %}
  261.     {% endif %}
  262. {% endblock %}