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