app/template/syntpl/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. {% if Category is not null and Category.name is defined %}
  10.     {% set body_class = 'page-product page-product-list page-product-list-category page-product-list-category-' ~ Category.id %}
  11. {% elseif search_form.vars.value and search_form.vars.value.name %}
  12.     {% set body_class = 'page-product page-product-list page-product-list-search' %}
  13. {% else %}
  14.     {% set body_class = 'page-product page-product-list page-product-list-top' %}
  15. {% endif %}
  16. {% block javascript %}
  17.     <script>
  18.         eccube.productsClassCategories = {
  19.             {% for Product in pagination %}
  20.             "{{ Product.id|escape('js') }}": {{ class_categories_as_json(Product)|raw }}{% if loop.last == false %}, {% endif %}
  21.             {% endfor %}
  22.         };
  23.         $(function() {
  24.             // 表示件数を変更
  25.             $('.disp-number').change(function() {
  26.                 var dispNumber = $(this).val();
  27.                 $('#disp_number').val(dispNumber);
  28.                 $('#pageno').val(1);
  29.                 $("#form1").submit();
  30.             });
  31.             // 並び順を変更
  32.             $('.order-by').change(function() {
  33.                 var orderBy = $(this).val();
  34.                 $('#orderby').val(orderBy);
  35.                 $('#pageno').val(1);
  36.                 $("#form1").submit();
  37.             });
  38.             $('.add-cart').on('click', function(e) {
  39.                 var $form = $(this).parents('li').find('form');
  40.                 // 個数フォームのチェック
  41.                 var $quantity = $form.parent().find('.quantity');
  42.                 if ($quantity.val() < 1) {
  43.                     $quantity[0].setCustomValidity('{{ '1以上で入力してください。'|trans }}');
  44.                     setTimeout(function() {
  45.                         loadingOverlay('hide');
  46.                     }, 100);
  47.                     return true;
  48.                 } else {
  49.                     $quantity[0].setCustomValidity('');
  50.                 }
  51.                 e.preventDefault();
  52.                 $.ajax({
  53.                     url: $form.attr('action'),
  54.                     type: $form.attr('method'),
  55.                     data: $form.serialize(),
  56.                     dataType: 'json',
  57.                     beforeSend: function(xhr, settings) {
  58.                         // Buttonを無効にする
  59.                         $('.add-cart').prop('disabled', true);
  60.                     }
  61.                 }).done(function(data) {
  62.                     // レスポンス内のメッセージをalertで表示
  63.                     $.each(data.messages, function() {
  64.                         $('#ec-modal-header').html(this);
  65.                     });
  66.                     $('#ec-modal-checkbox').prop('checked', true);
  67.                     // カートブロックを更新する
  68.                     $.ajax({
  69.                         url: '{{ url('block_cart') }}',
  70.                         type: 'GET',
  71.                         dataType: 'html'
  72.                     }).done(function(html) {
  73.                         var num = $(html).find('.ec-cartNavi__badge').html();
  74.                         $('.header-cart span').html(num);
  75.                     });
  76.                 }).fail(function(data) {
  77.                     alert('{{ 'カートへの追加に失敗しました。'|trans }}');
  78.                 }).always(function(data) {
  79.                     // Buttonを有効にする
  80.                     $('.add-cart').prop('disabled', false);
  81.                 });
  82.             });
  83.         });
  84.     </script>
  85. {% endblock %}
  86. {% block main %}
  87.     <div class="ec-productListRole">
  88.         <div class="ec-productListRole__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.                 {% if Category.CategoryImage.0 is defined or (Category.description is defined and Category.description is not empty) %}
  95.                     <div class="ec-productListCategory">
  96.                         {% if Category.CategoryImage.0 is defined %}
  97.                             <div class="ec-productListCategory__image">
  98.                                 {{ synResizeImage({
  99.                                     url: asset(Category.CategoryImage.0, 'save_image'),
  100.                                     pc: {width: 960, height: 960, type: 'contain'},
  101.                                     alt: Category.name,
  102.                                     loading: true,
  103.                                 }) }}
  104.                             </div>
  105.                         {% endif %}
  106.                         {% if Category.description is defined %}
  107.                             <div class="ec-productListCategory__content">
  108.                                 {{ Category.description|raw }}
  109.                             </div>
  110.                         {% endif %}
  111.                     </div>
  112.                 {% endif %}
  113.                 <div class="ec-searchnavRole">
  114.                     <form name="form1" id="form1" method="get" action="?">
  115.                         {% for item in search_form %}
  116.                             <input type="hidden" id="{{ item.vars.id }}"
  117.                                    name="{{ item.vars.full_name }}"
  118.                                    {% if item.vars.value is not empty %}value="{{ item.vars.value }}" {% endif %}/>
  119.                         {% endfor %}
  120.                     </form>
  121.                     <div class="ec-searchnavRole__topicpath">
  122.                         <ol class="ec-topicpath">
  123.                             <li class="ec-topicpath__item"><a href="{{ url('product_list') }}">{{ '全て'|trans }}</a>
  124.                             </li>
  125.                             {% if Category is not null %}
  126.                                 {% for Path in Category.path %}
  127.                                     <li class="ec-topicpath__divider">|</li>
  128.                                     <li class="ec-topicpath__item{% if loop.last %}--active{% endif %}"><a
  129.                                                 href="{{ url('product_list') }}?category_id={{ Path.id }}">{{ Path.name }}</a>
  130.                                     </li>
  131.                                 {% endfor %}
  132.                             {% endif %}
  133.                             {% if search_form.vars.value and search_form.vars.value.name %}
  134.                                 <li class="ec-topicpath__divider">|</li>
  135.                                 <li class="ec-topicpath__item">{{ '「%name%」の検索結果'|trans({ '%name%': search_form.vars.value.name }) }}</li>
  136.                             {% endif %}
  137.                         </ol>
  138.                     </div>
  139.                     <div class="ec-searchnavRole__infos">
  140.                         <div class="ec-searchnavRole__counter">
  141.                             {% if pagination.totalItemCount > 0 %}
  142.                                 {{ '<span class="ec-font-bold">%count%件</span><span>の商品が見つかりました</span>'|trans({ '%count%': pagination.totalItemCount })|raw }}
  143.                             {% else %}
  144.                                 <span>{{ 'お探しの商品は見つかりませんでした'|trans }}</span>
  145.                             {% endif %}
  146.                         </div>
  147.                         {% if pagination.totalItemCount > 0 %}
  148.                             <div class="ec-searchnavRole__actions">
  149.                                 <div class="ec-select">
  150.                                     {{ form_widget(disp_number_form, {'id': '', 'attr': {'class': 'disp-number'}}) }}
  151.                                     {{ form_widget(order_by_form, {'id': '', 'attr': {'class': 'order-by'}}) }}
  152.                                 </div>
  153.                             </div>
  154.                         {% endif %}
  155.                     </div>
  156.                 </div>
  157.                 {% if pagination.totalItemCount > 0 %}
  158.                     <div class="ec-shelfRole">
  159.                         <ul class="ec-shelfGrid">
  160.                             {% for Product in pagination %}
  161.                                 <li class="ec-shelfGrid__item">
  162.                                     <p class="ec-shelfGrid__item-image">
  163.                                         <a href="{{ url('product_detail', {'id': Product.id}) }}">
  164.                                             {{ synResizeImage({
  165.                                                 url: asset(Product.main_list_image, 'save_image'),
  166.                                                 pc: {width: 300, height: 300, type: 'cover'},
  167.                                                 alt: Product.name,
  168.                                                 noimage: asset('assets/img/noimage.jpg'),
  169.                                                 loading: true,
  170.                                             }) }}
  171.                                         </a>
  172.                                     </p>
  173.                                     <h3>{{ Product.name }}</h3>
  174.                                     {% if Product.description_list %}
  175.                                         <div class="ec-shelfGrid__description">{{ Product.description_list|raw|nl2br }}</div>
  176.                                     {% endif %}
  177.                                     <p class="price02-default">
  178.                                         {% if Product.hasProductClass %}
  179.                                             {% if Product.getPrice02Min == Product.getPrice02Max %}
  180.                                                 {{ Product.getPrice02IncTaxMin|price }}
  181.                                             {% else %}
  182.                                                 {{ Product.getPrice02IncTaxMin|price }} ~ {{ Product.getPrice02IncTaxMax|price }}
  183.                                             {% endif %}
  184.                                         {% else %}
  185.                                             {{ Product.getPrice02IncTaxMin|price }}
  186.                                         {% endif %}
  187.                                     </p>
  188.                                     {% if Synplgbase is defined and Synplgbase.ProductCustomerPriceOn %}
  189.                                         {% if Product.getPrice03Min is not null %}
  190.                                             <p class="price03-default">
  191.                                                 <span>会員価格</span>
  192.                                                 {% if Product.hasProductClass %}
  193.                                                     {% if Product.getPrice03Min is not null and Product.getPrice03Min == Product.getPrice03Max %}
  194.                                                         {{ Product.getPrice03IncTaxMin|price }}
  195.                                                     {% elseif Product.getPrice03Min is not null %}
  196.                                                         {{ Product.getPrice03IncTaxMin|price }}~{{ Product.getPrice03IncTaxMax|price }}
  197.                                                     {% endif %}
  198.                                                 {% elseif Product.getPrice03Max is not null %}
  199.                                                     {{ Product.getPrice03IncTaxMin|price }}
  200.                                                 {% endif %}
  201.                                             </p>
  202.                                         {% endif %}
  203.                                     {% endif %}
  204.                                 </li>
  205.                             {% endfor %}
  206.                         </ul>
  207.                     </div>
  208.                     <div class="ec-pagerRole">
  209.                         {% include "pager.twig" with {'pages': pagination.paginationData} %}
  210.                     </div>
  211.                 {% endif %}
  212.             {% endif %}
  213.         </div>
  214.     </div>
  215. {% endblock %}