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.     <hgroup class="c-heading-italic">
  88.         <h1 class="c-heading-italic__ja" style="font-size: 24px">
  89.             {% if Category is not null %}
  90.                 {{ Category.name }}の商品一覧
  91.             {% else %}
  92.                 全ての商品一覧
  93.             {% endif %}
  94.         </h1>
  95.         {#<p class="c-heading-italic__en">#}
  96.              {#{{ Category.name }}の商品一覧#}
  97.              {#{{ Category.name }}の商品一覧#}
  98.             {#{% if Category is not null and Category.id == 7 %}#}
  99.             {#    racket#}
  100.             {#{% elseif Category is not null and Category.id == 12 %}#}
  101.             {#    recommend#}
  102.             {#{% elseif Category is not null and Category.id == 8 %}#}
  103.             {#    ball#}
  104.             {#{% elseif Category is not null and Category.id == 10 %}#}
  105.             {#    shoes#}
  106.             {#{% elseif Category is not null and Category.id == 9 %}#}
  107.             {#    wear#}
  108.             {#{% elseif Category is not null and Category.id == 11 %}#}
  109.             {#    other#}
  110.             {#{% else %}#}
  111.             {#    product#}
  112.             {#{% endif %}#}
  113.         {#</p>#}
  114.     </hgroup>
  115.     {% if search_form.category_id.vars.errors|length > 0 %}
  116.         <div class="ec-searchnavRole">
  117.             <p class="errormsg text-danger">{{ 'ご指定のカテゴリは存在しません'|trans }}</p>
  118.         </div>
  119.     {% else %}
  120.         <div class="ec-searchnavRole">
  121.             <form name="form1" id="form1" method="get" action="?">
  122.                 {% for item in search_form %}
  123.                     <input type="hidden" id="{{ item.vars.id }}"
  124.                            name="{{ item.vars.full_name }}"
  125.                            {% if item.vars.value is not empty %}value="{{ item.vars.value }}" {% endif %}/>
  126.                 {% endfor %}
  127.             </form>
  128.           <!--  <div class="ec-searchnavRole__topicpath">
  129.                 <ol class="ec-topicpath">
  130.                     <li class="ec-topicpath__item"><a href="{{ url('product_list') }}">{{ '全て'|trans }}</a>
  131.                     </li>
  132.                     {% if Category is not null %}
  133.                         {% for Path in Category.path %}
  134.                             <li class="ec-topicpath__divider">|</li>
  135.                             <li class="ec-topicpath__item{% if loop.last %}--active{% endif %}"><a
  136.                                         href="{{ url('product_list') }}?category_id={{ Path.id }}">{{ Path.name }}</a>
  137.                             </li>
  138.                         {% endfor %}
  139.                     {% endif %}
  140.                     {% if search_form.vars.value and search_form.vars.value.name %}
  141.                         <li class="ec-topicpath__divider">|</li>
  142.                         <li class="ec-topicpath__item">{{ '「%name%」の検索結果'|trans({ '%name%': search_form.vars.value.name }) }}</li>
  143.                     {% endif %}
  144.                 </ol>
  145.             </div>-->
  146.             <div class="ec-searchnavRole__infos">
  147.                 <div class="ec-searchnavRole__counter">
  148.                     {% if pagination.totalItemCount > 0 %}
  149.                         <!--{{ '<span class="ec-font-bold">%count%件</span><span>の商品が見つかりました</span>'|trans({ '%count%': pagination.totalItemCount })|raw }}-->
  150.                     {% else %}
  151.                         <span>{{ 'お探しの商品は見つかりませんでした'|trans }}</span>
  152.                     {% endif %}
  153.                 </div>
  154.                 {% if pagination.totalItemCount > 0 %}
  155.                     <div class="ec-searchnavRole__actions">
  156.                         <div class="ec-select">
  157.                             {{ form_widget(search_form.disp_number, {'id': '', 'attr': {'class': 'disp-number'}}) }}
  158.                             {{ form_widget(search_form.orderby, {'id': '', 'attr': {'class': 'order-by'}}) }}
  159.                         </div>
  160.                     </div>
  161.                 {% endif %}
  162.             </div>
  163.         </div>
  164.         {% if pagination.totalItemCount > 0 %}
  165.             <div class="ec-shelfRole">
  166.                 <div class="l-ec-newItemRole__list--top p-ec-newItemRole__list">
  167.                     {% for Product in pagination %}
  168.                         <div class="p-ec-newItemRole__listItem">
  169.                             <a href="{{ url('product_detail', {'id': Product.id}) }}" class="p-ec-newItemRole__link">
  170.                                 <div class="p-ec-newItemRole__image"><img src="{{ asset(Product.main_list_image|no_image_product, 'save_image') }}" /></div>
  171.                                <div class="p-ec-newItemRole__content">
  172.                                 <div class="p-ec-newItemRole__categories">
  173.                                     {% for ProductCategory in Product.ProductCategories %}
  174.                                         <span class="p-ec-newItemRole__category">{{ ProductCategory.Category.name }}</span>
  175.                                     {% endfor %}
  176.                                 </div>
  177.                                 {% if Product.Tags %}
  178.                                     {% for Tag in Product.Tags %}
  179.                                     <div class="p-ec-newItemRole__label">{{ Tag.name }}</div>
  180.                                     {% endfor %}
  181.                                 {% endif %}
  182.                                 <p class="ec-newItemRole__listItemTitle">{{ Product.name }}</p>
  183.                                    
  184.                                     {% if Product.description_list %}
  185.                                         <p class="p-ec-newItemRole__description">{{ Product.description_list|raw|nl2br }}</p>
  186.                                     {% endif %}
  187.                                     <p class="ec-newItemRole__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.                                         <span class="ec-newItemRole__tax">(税込)</span>
  198.                                     </p>
  199.                                </div>
  200.                             </a>
  201.                             {% if Product.stock_find %}
  202.                                 {% set form = forms[Product.id] %}
  203.                                 <div class="p-ec-newItemRole__select">
  204.                                     <form name="form{{ Product.id }}" id="productForm{{ Product.id }}" action="{{ url('product_add_cart', {id:Product.id}) }}" method="post">
  205.                                         <div class="p-ec-productRole__actions">
  206.                                             {% if form.classcategory_id1 is defined %}
  207.                                                 <div class="">
  208.                                                     {{ form_widget(form.classcategory_id1) }}
  209.                                                     {{ form_errors(form.classcategory_id1) }}
  210.                                                 </div>
  211.                                                 {% if form.classcategory_id2 is defined %}
  212.                                                     <div class="">
  213.                                                         {{ form_widget(form.classcategory_id2) }}
  214.                                                         {{ form_errors(form.classcategory_id2) }}
  215.                                                     </div>
  216.                                                 {% endif %}
  217.                                             {% endif %}
  218.                                             <div class="ec-numberInput"><span>{{ '数量'|trans }}</span>
  219.                                                 {{ form_widget(form.quantity, {'attr': {'class': 'quantity'}}) }}
  220.                                                 {{ form_errors(form.quantity) }}
  221.                                             </div>
  222.                                         </div>
  223.                                         {{ form_rest(form) }}
  224.                                     </form>
  225.                                 </div>
  226.                                 <div class="p-ec-newItemRole__btn">
  227.                                     <button type="submit" class="p-ec-newItemRole__btnLink" data-cartid="{{ Product.id }}" form="productForm{{ Product.id }}">
  228.                                         {{ 'カートに入れる'|trans }}
  229.                                     </button>
  230.                                 </div>
  231.                             {% else %}
  232.                                 <div class="ec-productRole__btn">
  233.                                     <button type="button" class="ec-blockBtn--action" disabled="disabled">
  234.                                         {{ 'ただいま品切れ中です。'|trans }}
  235.                                     </button>
  236.                                 </div>
  237.                             {% endif %}
  238.                         </div>
  239.                     {% endfor %}
  240.                 </div>
  241.             </div>
  242.             <div class="ec-modal">
  243.                 <div class="ec-modal-overlay">
  244.                     <div class="ec-modal-wrap">
  245.                         <span class="ec-modal-close"><span class="ec-icon"><img src="{{ asset('assets/icon/cross-dark.svg') }}" alt=""/></span></span>
  246.                         <div id="ec-modal-header" class="text-center">{{ 'カートに追加しました。'|trans }}</div>
  247.                         <div class="ec-modal-box">
  248.                             <div class="ec-role ec-modal-box__btns">
  249.                                 <span class="ec-inlineBtn--cancel ec-inlineBtn--addBorder ec-inlineBtn--fontNormal ec-modal-box__btn">{{ 'お買い物を続ける'|trans }}</span>
  250.                                 <a href="{{ url('cart') }}" class="ec-inlineBtn--action ec-modal-box__btn">{{ '購入へ進む'|trans }}</a>
  251.                             </div>
  252.                         </div>
  253.                     </div>
  254.                 </div>
  255.             </div>
  256.             <div class="ec-pagerRole">
  257.                 {% include "pager.twig" with {'pages': pagination.paginationData} %}
  258.             </div>
  259.         {% endif %}
  260.     {% endif %}
  261.     <div class="u-wide-screen u-bg-gray">
  262.         <div class="l-new-product c-new-product">
  263.             <hgroup class="c-heading-italic">
  264.                 <h1 class="c-heading-italic__ja--center">
  265.                 新着商品一覧
  266.                 </h1>
  267.                 <p class="c-heading-italic__en--center">
  268.                 new items
  269.                 </p>
  270.             </hgroup>
  271.             <div class="l-ec-newItemRole__list--top p-ec-newItemRole__list">
  272.             
  273.             <!-- 商品開始 -->
  274.             {% if pagination.totalItemCount > 0 %}
  275.            {% for Product in pagination|slice(0, 4) %}
  276.             <div class="p-ec-newItemRole__listItem">
  277.                 <a href="{{ url('product_detail', {'id': Product.id}) }}" class="p-ec-newItemRole__link">
  278.                     <div class="p-ec-newItemRole__image"><img src="{{ asset(Product.main_list_image|no_image_product, 'save_image') }}" /></div>
  279.                     <div class="p-ec-newItemRole__content">
  280.                     <p class="ec-newItemRole__listItemTitle">{{ Product.name }}</p>
  281.                     {% if Product.description_list %}
  282.                     <p class="p-ec-newItemRole__description">{{ Product.description_list|raw|nl2br }}</p>
  283.                     {% endif %}
  284.                     <p class="ec-newItemRole__Price">
  285.                         {% if Product.hasProductClass %}
  286.                             {% if Product.getPrice02Min == Product.getPrice02Max %}
  287.                                 {{ Product.getPrice02IncTaxMin|price }}
  288.                             {% else %}
  289.                                 {{ Product.getPrice02IncTaxMin|price }} ~ {{ Product.getPrice02IncTaxMax|price }}
  290.                             {% endif %}
  291.                         {% else %}
  292.                             {{ Product.getPrice02IncTaxMin|price }}
  293.                         {% endif %}
  294.                         <span class="ec-newItemRole__tax">(税込)</span></p>
  295.                     </div>
  296.                 </a>
  297.                 {% if Product.Tags %}
  298.                     {% for Tag in Product.Tags %}
  299.                     <div class="p-ec-newItemRole__label">{{ Tag.name }}</div>
  300.                     {% endfor %}
  301.                 {% endif %}
  302.                 <!-- 商品終了 -->
  303.             </div>
  304.              {% endfor %}
  305.               {% endif %}
  306.             
  307.         </div>
  308.         <div class="l-btnNewItem">
  309.             <a href="{{ url('product_list') }}" class="c-btn--white">
  310.             <span>新着商品一覧をみる</span>
  311.             <img src="{{ asset('assets/img/icon/icon-arrow-right-path-green.svg') }}" width="20" height="16" alt="" />
  312.             </a>
  313.         </div>
  314.         </div>
  315.     </div>
  316. {% endblock %}