app/template/kinkodo/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. <div class="main-top">
  88.         {# ページタイトル #}
  89.         <div id="pagetitle">
  90.             <h2>
  91.                 PRODUCT
  92.                 <small>商品</small>
  93.             </h2>
  94.             <div class="image">
  95.                 <img src="{{ asset('assets/assets/images/pagetitle-image-product.jpg') }}">
  96.             </div>
  97.         </div>
  98.     </div>
  99.     {% if search_form.category_id.vars.errors|length > 0 %}
  100.         <div class="ec-searchnavRole">
  101.             <p class="errormsg text-danger">{{ 'ご指定のカテゴリは存在しません'|trans }}</p>
  102.         </div>
  103.     {% else %}
  104.         <div class="ec-searchnavRole">
  105.             <form name="form1" id="form1" method="get" action="?">
  106.                 {% for item in search_form %}
  107.                     <input type="hidden" id="{{ item.vars.id }}"
  108.                            name="{{ item.vars.full_name }}"
  109.                            {% if item.vars.value is not empty %}value="{{ item.vars.value }}" {% endif %}/>
  110.                 {% endfor %}
  111.             </form>
  112.             <div class="ec-searchnavRole__topicpath">
  113.                 <ol class="ec-topicpath">
  114.                     <li class="ec-topicpath__item"><a href="{{ url('product_list') }}">{{ '全て'|trans }}</a>
  115.                     </li>
  116.                     {% if Category is not null %}
  117.                         {% for Path in Category.path %}
  118.                             <li class="ec-topicpath__divider">|</li>
  119.                             <li class="ec-topicpath__item{% if loop.last %}--active{% endif %}"><a
  120.                                         href="{{ url('product_list') }}?category_id={{ Path.id }}">{{ Path.name }}</a>
  121.                             </li>
  122.                         {% endfor %}
  123.                     {% endif %}
  124.                     {% if search_form.vars.value and search_form.vars.value.name %}
  125.                         <li class="ec-topicpath__divider">|</li>
  126.                         <li class="ec-topicpath__item">{{ '「%name%」の検索結果'|trans({ '%name%': search_form.vars.value.name }) }}</li>
  127.                     {% endif %}
  128.                 </ol>
  129.             </div>
  130.             <div class="ec-searchnavRole__infos">
  131.                 <div class="ec-searchnavRole__counter">
  132.                     {% if pagination.totalItemCount > 0 %}
  133.                         {{ '<span class="ec-font-bold">%count%件</span><span>の商品が見つかりました</span>'|trans({ '%count%': pagination.totalItemCount })|raw }}
  134.                     {% else %}
  135.                         <span>{{ 'お探しの商品は見つかりませんでした'|trans }}</span>
  136.                     {% endif %}
  137.                 </div>
  138.                 {% if pagination.totalItemCount > 0 %}
  139.                     <div class="ec-searchnavRole__actions">
  140.                         <div class="ec-select">
  141.                             {{ form_widget(search_form.disp_number, {'id': '', 'attr': {'class': 'disp-number'}}) }}
  142.                             {{ form_widget(search_form.orderby, {'id': '', 'attr': {'class': 'order-by'}}) }}
  143.                         </div>
  144.                     </div>
  145.                 {% endif %}
  146.             </div>
  147.         </div>
  148.         {% if pagination.totalItemCount > 0 %}
  149. <section id="carender">
  150. {# タグ:おすすめ商品の商品を1件表示 #}
  151. {% set recomendTag = 13 %}
  152. {% if Category is not null %}
  153. {# 現在のカテゴリ取得 #}
  154. {% set lastCategoryId = null %}
  155. {% for Path in Category.path %}
  156.     {% if loop.last %}
  157.         {% set lastCategoryId = Path.id %}
  158.     {% endif %}
  159. {% endfor %}
  160. {% set desiTag = repository("Eccube\\Entity\\Category").find(lastCategoryId) %}
  161. {% 
  162. set products = repository("Eccube\\Entity\\Product")
  163. .createQueryBuilder('p')
  164.     .innerJoin('p.ProductCategories', 'pc')
  165.     .where('pc.Category = :category_id')
  166.     .andWhere('p.Status = 1')
  167.     .setParameter('category_id', desiTag)
  168.     .orderBy('p.update_date', 'DESC')
  169.     .setMaxResults(9999)
  170.     .getQuery()
  171.     .getResult()
  172. %}
  173. {% else %}
  174. {% set desiTag = repository("Eccube\\Entity\\Category").find(recomendTag) %}
  175. {% 
  176. set products = repository("Eccube\\Entity\\Product")
  177. .createQueryBuilder('p')
  178.     .innerJoin('p.ProductCategories', 'pc')
  179.     .where('pc.Category = :category_id')
  180.     .andWhere('p.Status = 1')
  181.     .setParameter('category_id', desiTag)
  182.     .orderBy('p.update_date', 'DESC')
  183.     .setMaxResults(9999)
  184.     .getQuery()
  185.     .getResult()
  186. %}
  187. {% endif %}
  188.             {% if products %}
  189.             
  190.                         <div class="recommendation">
  191.                             <p class="title">カテゴリ別おすすめ商品</p>
  192.     <div class="contents">
  193. {% set break = false %}
  194. {% for Product in products if not break %}
  195.   
  196.         {% set hasCategory = Product.ProductCategories|filter(pc => pc.Category.id == recomendTag)|length > 0 %}
  197.         {% if hasCategory %}
  198.             
  199.             <div class="block">
  200.                                  <a href="{{ url('product_detail', {'id': Product.id}) }}">
  201.                                   {% if Product.stock_find %}
  202.                                     <div class="image">
  203.                                         <img src="{{ asset(Product.main_list_image|no_image_product, 'save_image') }}" alt="{{ Product.name }}" {% if loop.index > 5 %} loading="lazy"{% endif %}>
  204.                                     </div>
  205. {% else %}
  206. <div class="image souldout">
  207.                                         <img src="{{ asset(Product.main_list_image|no_image_product, 'save_image') }}" alt="{{ Product.name }}" {% if loop.index > 5 %} loading="lazy"{% endif %}>
  208.                                     </div>
  209. {% endif %}
  210.                                     <p class="title">
  211.                                         {{ Product.name }}
  212.                                     </p>
  213.                                     {% if Product.code_min is not empty %}<p class="type">{{ Product.code_min }}</p>{% endif %}
  214. {# 価格表示ここから #}
  215. {# 在庫があるかどうか #}
  216. {% if Product.stock_find %}
  217. {# 販売価格にテキストがあるかどうか #}
  218. {% if Product.ViewData(11) is not empty %}
  219. <p class="price"><span>{{Product.ViewData(11)}}</span></p>
  220. {# 販売価格にテキストがない場合価格を表示 0円の場合は準備中のテキストを表示 #}
  221. {% else %}
  222. {% if Product.hasProductClass -%}
  223.                             {% if Product.getPrice02IncTaxMin == Product.getPrice02IncTaxMax %}
  224.                                 <p class="price"><span>{% if Product.getPrice02IncTaxMin == 0 %}{{ include('Block/textcampaign.twig') }}</span>{% else %}{{ Product.getPrice02IncTaxMin|price }}</span>/100冊{% endif %}</p>
  225.                             {% else %}
  226.                                 <p class="price"><span>{{ Product.getPrice02IncTaxMin|price }}
  227.                                         ~
  228.                                         {{ Product.getPrice02IncTaxMax|price }}</span>/100冊</p>
  229.                             {% endif %}
  230.                         {% else %}
  231.                        <p class="price"><span>{% if Product.getPrice02IncTaxMin == 0 %}{{ include('Block/textcampaign.twig') }}</span>{% else %}{{ Product.getPrice02IncTaxMin|price }}</span>/100冊{% endif %}</p>
  232.                         {% endif %}
  233. {% endif %}
  234. {# 在庫がない場合 #}
  235.  {% else %}
  236.  {# 販売価格にテキストがあるかどうか #}
  237. {% if Product.ViewData(11) is not empty %}
  238. <p class="price"><span>{{Product.ViewData(11)}}</span></p>
  239. {# 販売価格にテキストがない場合 #}
  240. {% else %}
  241. <p class="price"><span>{{ include('Block/textcampaign.twig') }}</span></p>
  242. {% endif %}
  243. {% endif %}
  244. {# 価格表示ここまで #}
  245.                                 </a>
  246.                             </div>
  247.             {% set break = true %}
  248.         {% else %}
  249.         
  250.         {% endif %}
  251. {% endfor %}
  252. </div>
  253.                         
  254.                         </div>
  255.   {% endif %}
  256.                         
  257.                         <div class="contents">
  258.            
  259.                     {% for Product in pagination %}
  260. <div class="block">
  261.                                  <a href="{{ url('product_detail', {'id': Product.id}) }}">
  262.                                   {% if Product.stock_find %}
  263.                                     <div class="image">
  264.                                         <img src="{{ asset(Product.main_list_image|no_image_product, 'save_image') }}" alt="{{ Product.name }}" {% if loop.index > 5 %} loading="lazy"{% endif %}>
  265.                                     </div>
  266. {% else %}
  267. <div class="image souldout">
  268.                                         <img src="{{ asset(Product.main_list_image|no_image_product, 'save_image') }}" alt="{{ Product.name }}" {% if loop.index > 5 %} loading="lazy"{% endif %}>
  269.                                     </div>
  270. {% endif %}
  271.                                     <p class="title">
  272.                                         {{ Product.name }}
  273.                                     </p>
  274.                                     {% if Product.code_min is not empty %}<p class="type">{{ Product.code_min }}</p>{% endif %}
  275. {# 価格表示ここから #}
  276. {# 在庫があるかどうか #}
  277. {% if Product.stock_find %}
  278. {# 販売価格にテキストがあるかどうか #}
  279. {% if Product.ViewData(11) is not empty %}
  280. <p class="price"><span>{{Product.ViewData(11)}}</span></p>
  281. {# 販売価格にテキストがない場合価格を表示 0円の場合は準備中のテキストを表示 #}
  282. {% else %}
  283. {% if Product.hasProductClass -%}
  284.                             {% if Product.getPrice02IncTaxMin == Product.getPrice02IncTaxMax %}
  285.                                 <p class="price"><span>{% if Product.getPrice02IncTaxMin == 0 %}{{ include('Block/textcampaign.twig') }}</span>{% else %}{{ Product.getPrice02IncTaxMin|price }}</span>/100冊{% endif %}</p>
  286.                             {% else %}
  287.                                 <p class="price"><span>{{ Product.getPrice02IncTaxMin|price }}
  288.                                         ~
  289.                                         {{ Product.getPrice02IncTaxMax|price }}</span>/100冊</p>
  290.                             {% endif %}
  291.                         {% else %}
  292.                        <p class="price"><span>{% if Product.getPrice02IncTaxMin == 0 %}{{ include('Block/textcampaign.twig') }}</span>{% else %}{{ Product.getPrice02IncTaxMin|price }}</span>/100冊{% endif %}</p>
  293.                         {% endif %}
  294. {% endif %}
  295. {# 在庫がない場合 #}
  296.  {% else %}
  297.  {# 販売価格にテキストがあるかどうか #}
  298. {% if Product.ViewData(11) is not empty %}
  299. <p class="price"><span>{{Product.ViewData(11)}}</span></p>
  300. {# 販売価格にテキストがない場合 #}
  301. {% else %}
  302. <p class="price"><span>{{ include('Block/textcampaign.twig') }}</span></p>
  303. {% endif %}
  304. {% endif %}
  305. {# 価格表示ここまで #}
  306.                                     
  307.                                 </a>
  308.                             </div>
  309.                     {% endfor %}
  310.                     </div>
  311.                     </section>
  312.                
  313.             <div class="ec-modal">
  314.                 <div class="ec-modal-overlay">
  315.                     <div class="ec-modal-wrap">
  316.                         <span class="ec-modal-close"><span class="ec-icon"><img src="{{ asset('assets/icon/cross-dark.svg') }}" alt=""/></span></span>
  317.                         <div id="ec-modal-header" class="text-center">{{ 'カートに追加しました。'|trans }}</div>
  318.                         <div class="ec-modal-box">
  319.                             <div class="ec-role">
  320.                                 <span class="ec-inlineBtn--cancel">{{ 'お買い物を続ける'|trans }}</span>
  321.                                 <a href="{{ url('cart') }}" class="ec-inlineBtn--action">{{ 'カートへ進む'|trans }}</a>
  322.                             </div>
  323.                         </div>
  324.                     </div>
  325.                 </div>
  326.             </div>
  327.             <div class="ec-pagerRole">
  328.                 {% include "pager.twig" with {'pages': pagination.paginationData} %}
  329.             </div>
  330.         {% endif %}
  331.     {% endif %}
  332. {% endblock %}