app/template/uarts/Product/list.twig line 1

Open in your IDE?
  1. {% extends 'default_frame.twig' %}
  2. {% set body_id = 'product_page' %}
  3. {% block javascript %}
  4. <script>
  5.     {# eccube.productsClassCategories = {{% for Product in pagination %}"{{ Product.id|escape('js') }}": { { class_categories_as_json(Product) | raw } } {% if loop.last == false %}, {% endif %}{% endfor %}}; #}
  6.     $(function () {
  7.         // 表示件数を変更
  8.         $('.disp-number').change(function () {
  9.             console.log("hoge");
  10.             var dispNumber = $(this).val();
  11.             $('#disp_number').val(dispNumber);
  12.             $('#pageno').val(1);
  13.             $("#form1").submit();
  14.         });
  15.         // 並び順を変更
  16.         $('.order-by').change(function () {
  17.             var orderBy = $(this).val();
  18.             $('#orderby').val(orderBy);
  19.             $('#pageno').val(1);
  20.             $("#form1").submit();
  21.         });
  22.         $('.add-cart').on('click', function (e) {
  23.             var $form = $(this).parents('li').find('form');
  24.             // 個数フォームのチェック
  25.             var $quantity = $form.parent().find('.quantity');
  26.             if ($quantity.val() < 1) {
  27.                 $quantity[0].setCustomValidity('{{ '1以上で入力してください。'|trans }}');
  28.                 setTimeout(function () {
  29.                     loadingOverlay('hide');
  30.                 }, 100);
  31.                 return true;
  32.             } else {
  33.                 $quantity[0].setCustomValidity('');
  34.             }
  35.             e.preventDefault();
  36.             $.ajax({
  37.                 url: $form.attr('action'),
  38.                 type: $form.attr('method'),
  39.                 data: $form.serialize(),
  40.                 dataType: 'json',
  41.                 beforeSend: function (xhr, settings) {
  42.                     // Buttonを無効にする
  43.                     $('.add-cart').prop('disabled', true);
  44.                 }
  45.             }).done(function (data) {
  46.                 // レスポンス内のメッセージをalertで表示
  47.                 $.each(data.messages, function () {
  48.                     $('#ec-modal-header').text(this);
  49.                 });
  50.                 $('.ec-modal').show()
  51.                 // カートブロックを更新する
  52.                 $.ajax({
  53.                     url: '{{ url('block_cart') }}',
  54.                     type: 'GET',
  55.                     dataType: 'html'
  56.                 }).done(function (html) {
  57.                     $('.ec-headerRole__cart').html(html);
  58.                 });
  59.             }).fail(function (data) {
  60.                 alert('{{ 'カートへの追加に失敗しました。'|trans }}');
  61.             }).always(function (data) {
  62.                 // Buttonを有効にする
  63.                 $('.add-cart').prop('disabled', false);
  64.             });
  65.         });
  66.     });
  67.     $('.ec-modal-wrap').on('click', function (e) {
  68.         // モーダル内の処理は外側にバブリングさせない
  69.         e.stopPropagation();
  70.     });
  71.     $('.ec-modal-overlay, .ec-modal, .ec-modal-close, .ec-inlineBtn--cancel').on('click', function () {
  72.         $('.ec-modal').hide()
  73.     });
  74. </script>
  75. {% endblock %}
  76. {% block sub_area %}
  77.         <ul class="pankuzu">
  78.             <li><a href="{{ url('homepage') }}">トップ</a></li>
  79.             {% if Category is not null %}
  80.                     {% for Path in Category.path %}
  81.                         <li>
  82.                             <a href="{{ url('product_list') }}?category_id={{ Path.id }}">{{ Path.name }}</a>
  83.                         </li>
  84.                     {% endfor %}
  85.             {% else %}
  86.             <li>
  87.             <a href="{{ url('product_list') }}">{{subtitle}}</a>
  88.             </li>
  89.             {% endif %}
  90.         </ul>
  91. {% endblock %}
  92. {% block main %}
  93. {% if search_form.category_id.vars.errors|length > 0 %}
  94. <div class="ec-searchnavRole">
  95.     <p class="errormsg text-danger">{{ 'ご指定のカテゴリは存在しません'|trans }}</p>
  96. </div>
  97. {% else %}
  98. <form name="form1" id="form1" method="get" action="?">
  99.     {% for item in search_form %}
  100.     <input type="hidden" id="{{ item.vars.id }}" name="{{ item.vars.full_name }}" {% if item.vars.value is not empty
  101.         %}value="{{ item.vars.value }}" {% endif %} />
  102.     {% endfor %}
  103. </form>
  104. <div class="main_ttl_wrap">
  105.     {% if Category is not null %}
  106.     {% for Path in Category.path %}
  107.     {% if loop.last %}
  108.     <h2 class="main_ttl">{{ Path.name }}</h2>
  109.     {% endif %}
  110.     {% endfor %}
  111.     {% else %}
  112.     <h2 class="main_ttl">商品一覧</h2>
  113.     {% endif %}
  114. </div>
  115. <div class="sortarea_wrap">
  116.     {% if pagination.totalItemCount > 0 %}
  117.     <p><span class="txt_red">{{pagination.totalItemCount}}件</span>の商品がございます。</p>
  118.     {% else %}
  119.     <p>お探しの商品は見つかりませんでした</p>
  120.     {% endif %}
  121.     <ul class="sortarea">
  122.         <li>並び替え</li>
  123.         <li>
  124.             {{ form_widget(search_form.disp_number, {'id': '', 'attr': {'class': 'disp-number'}}) }}
  125.         </li>
  126.         <li class="selectarea">
  127.             {{ form_widget(search_form.orderby, {'id': '', 'attr': {'class': 'order-by'}}) }}
  128.         </li>
  129.     </ul>
  130. </div>
  131. {% if pagination.totalItemCount > 0 %}
  132. {% include "pager.twig" with {'pages': pagination.paginationData} %}
  133. <ul class="list_item">
  134.     {% for Product in pagination %}
  135.     {# {% set frame_width = getProduct_field(Product.id,"frame_width") %}
  136.     {% set frame_thickness = getProduct_field(Product.id,"frame_thickness") %} #}
  137.     {% set minPrice = CustomProductFindWhere(Product,"min_price") %}
  138.     {% set maxPrice = CustomProductFindWhere(Product,"max_price") %}
  139.     {% set maxTotal = CustomProductFindWhere(Product,"max_total") %}
  140.     <li>
  141.         <a href="{{ url('product_detail', {'id': Product.id}) }}">
  142.             <div class="list_item_img">
  143.                 <img src="{{ asset(Product.MainListImage|no_image_product, 'save_image') }}" alt="{{ Product.name }}">
  144.             </div>
  145.         </a>
  146.         <p class="list_item_name">{{ Product.name }}</p>
  147.         {% if Product.getMinLength %}
  148.         <p class="list_item_detail">フレーム幅:{{Product.getMinLength|number_format()}}mm</p>
  149.         {% endif %}
  150.         {% if Product.getMaxLength %}
  151.         <p class="list_item_detail">フレーム厚み:{{Product.getMaxLength|number_format()}}mm</p>
  152.         {% endif %}
  153.         {% if maxTotal %}
  154.         <p class="list_item_detail">ヨコ・タテ合計: {{ maxTotal|number_format() }}mmまで</p>
  155.         {% endif %}
  156.         <p class="list_item_price">
  157.             {% if minPrice != maxPrice and maxPrice is not null %}
  158.             {{ minPrice|number_format() }}~{{ maxPrice|number_format()
  159.             }}
  160.             {% elseif minPrice is not null %}
  161.             {{ minPrice|number_format() }}
  162.             {% elseif maxPrice is not null %}
  163.             {{ maxPrice|number_format() }}
  164.         
  165.             {% elseif Product.hasProductClass %}
  166.             {% if Product.getPrice02Min == Product.getPrice02Max %}
  167.             {{ Product.getPrice02IncTaxMin|number_format() }}
  168.             {% else %}
  169.             {{ Product.getPrice02IncTaxMin|number_format() }} ~ {{ Product.getPrice02IncTaxMax|number_format() }}
  170.             {% endif %}
  171.             {% else %}
  172.             {{ Product.getPrice02IncTaxMin|number_format() }}
  173.             {% endif %}
  174.             <span>円 (税込)</span>
  175.         </p>
  176.     </li>
  177.     {% endfor %}
  178. </ul>
  179. {% include "pager.twig" with {'pages': pagination.paginationData} %}
  180. {% endif %}
  181. {% endif %}
  182. {% endblock %}