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('{{ 'front.product.invalid_quantity'|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('{{ 'front.product.add_cart_error'|trans }}');
  71.                 }).always(function(data) {
  72.                     // Buttonを有効にする
  73.                     $('.add-cart').prop('disabled', false);
  74.                 });
  75.             });
  76.         });
  77.         {# ページ内のフリーエリアの高さをすべて取得し、すべてのフリーエリアをその高さにあわせる #}
  78.         $(document).ready(function(){
  79.             var maxOuterHeight = 0;
  80.             $('.free_area').each(function() {
  81.                 var elementOuterHeight = $(this).outerHeight();
  82.                 if (elementOuterHeight > maxOuterHeight) {
  83.                     maxOuterHeight = elementOuterHeight;
  84.                 }
  85.             });
  86.             if(maxOuterHeight > 0 ){
  87.                 $('.free_area').each(function(){
  88.                     $(this).outerHeight(maxOuterHeight);
  89.                 })
  90.             }
  91.         });
  92.         $('.ec-modal-wrap').on('click', function (e) { // モーダル内の処理は外側にバブリングさせない
  93.             e.stopPropagation();
  94.         });
  95.         $('.ec-modal-overlay, .ec-modal, .ec-modal-close, .ec-inlineBtn--cancel').on('click', function () {
  96.             $('.ec-modal').hide()
  97.         });
  98.     </script>
  99. {% endblock %}
  100. {% set category_id = app.request.query.get('category_id') %}
  101. {% set colors =
  102.     [
  103.         {
  104.             code: "#000000",
  105.         },
  106.         {
  107.             code: "#ffffff",
  108.         },
  109.     ]
  110. %}
  111. {% set category_descriptions = [
  112.     {
  113.         id: 2,
  114.         description: "あなたの想いを、置ける場所"
  115.     },
  116.     {
  117.         id: 1,
  118.         description: "想いそのものを、かたちに"
  119.     },
  120.     {
  121.         id: 3,
  122.         description: "あなたの想いに、らしさを加える"
  123.     },
  124.     {
  125.         id: 4,
  126.         description: "おすすめ、人気のコーディネート"
  127.     },
  128.     {
  129.         id: 21,
  130.         description: "お仏壇のない、小さなご供養"
  131.     },
  132. ] %}
  133. {% set parent_category_ids = [1,2,3,4,21] %}
  134. {% block main %}
  135.     {% if search_form.category_id.vars.errors|length > 0 %}
  136.         <div class="ec-searchnavRole"> <p class="errormsg text-danger">{{ 'front.product.search__category_not_found'|trans }}</p>
  137.         </div>
  138.     {% else %}
  139.         <div class="pt-24 pb-10 md:py-6 xl:px-7 max-w-[1120px] mx-auto lg:mx-0">
  140.             <div
  141.                 class="w-full flex flex-col font-extralight">
  142.                 {% if Category.Parent is not null %}
  143.                     {% set parent_category_name = Category.Parent.name %}
  144.                     {% set parent_category_id = Category.Parent.id %}
  145.                     <h1 class="font-extralight text-[40px] tracking-[8px] md:tracking-[6px] md:text-[22px] mb-5 md:mb-2">
  146.                         {% if parent_category_id == 2 %}
  147.                             お仏壇・ステージ
  148.                         {% elseif Category.id == 3 %}
  149.                             仏具・日用品
  150.                         {% else %}
  151.                             {{parent_category_name}}
  152.                         {% endif %}
  153.                     </h1>
  154.                     {% for category_description in category_descriptions %}
  155.                         {% if parent_category_id == category_description.id %}
  156.                             <p class="text-[22px] font-extralight md:text-sm">{{category_description.description}}</p>
  157.                         {% endif %}
  158.                     {% endfor %}
  159.                     {% else %}
  160.                     <h1 class="font-extralight text-[40px] tracking-[8px] md:tracking-[6px] md:text-[22px] mb-5 md:mb-2">
  161.                          {% if Category.id == 2 %}
  162.                             お仏壇・ステージ
  163.                         {% elseif Category.id == 3 %}
  164.                             仏具・日用品
  165.                         {% else %}
  166.                             {{Category.name}}
  167.                         {% endif %}
  168.                     </h1>
  169.                     {% for category_description in category_descriptions %}
  170.                         {% if Category.id == category_description.id %}
  171.                             <p class="text-2xl font-extralight md:text-sm tracking-[2px]">{{category_description.description}}</p>
  172.                         {% endif %}
  173.                     {% endfor %}
  174.                 {% endif %}
  175.             </div>
  176.         </div>
  177.         {# 商品一覧 #}
  178.         <div class="w-full max-w-[1120px] mx-auto xl:px-7">
  179.             <ul class="gap-4 md:gap-3 grid grid-cols-4 md:grid-cols-2 font-extralight">
  180.                 {% set category_length = Category.getChildren|length %}
  181.                 {# MEMO: isParentは中カテゴリの場合、trueとなる #}
  182.                 {% set isParent = Category.Parent is not null %}
  183.                 <a
  184.                     {% if isParent %}
  185.                         href="{{ url('product_list', {'category_id': Category.Parent.id}) }}"
  186.                     {% else %}
  187.                         href="{{ url('product_list', {'category_id': Category.id}) }}"
  188.                     {% endif %}>
  189.                     <li class="tabs w-full max-w-[calc(100%÷{{ category_length + 1 }})] border-[#E2DFD6] border hover:opacity-70 duration-700 py-3 md:text-sm rounded text-center {% if category_id in parent_category_ids %} bg-[#E2DFD6] {% endif %}">すべて</li>
  190.                 </a>
  191.                 {% set childCategories = isParent ? Category.Parent.Children : Category.Children %}
  192.                 {% for category in childCategories %}
  193.                     <a href="{{ url('product_list', {'category_id': category.id}) }}">
  194.                         <li class="tabs w-full max-w-[calc(100%÷{{ category_length + 1 }})] border-[#E2DFD6] border hover:opacity-70 duration-700 py-3 md:text-sm rounded text-center {% if category.id == category_id %} bg-[#E2DFD6] {% else %} bg-white {% endif %}">
  195.                             {{category.name}}
  196.                         </li>
  197.                     </a>
  198.                 {% endfor %}
  199.             </ul>
  200.             <div class="tab-content">
  201.                 <ul class="flex gap-8 grid grid-cols-3 lg:grid-cols-2 justify-center mt-16 md:mt-8 md:gap-4 md:px-0 mx-0 mx-auto">
  202.                 {% for Product in pagination %}
  203.                     <li class="w-full shadow-lg hover:opacity-70 duration-700 lg:w-full h-auto">
  204.                         <a href="{{ url('product_detail', {'id': Product.id}) }}" class="flex flex-col h-full">
  205.                             <div>
  206.                                 <img src="{{ asset(Product.main_list_image|no_image_product, 'save_image') }}" alt="{{ Product.name }}" class="w-full h-[350px] md:h-[150px]">
  207.                                 <div class="px-8 py-6 md:p-3 bg-white min-h-[292px] md:min-h-[195px] h-auto">
  208.                                     <div class="min-h-10 flex flex-col items-center justify-end h-auto">
  209.                                         <p class="text-sm text-center md:text-[10px] h-auto tracking-[0.1em] mb-1 flex mt-auto min-h-5">
  210.                                             {% if Product.name_kana %}
  211.                                                 {{ Product.name_kana }}
  212.                                             {% endif %}
  213.                                         </p>
  214.                                         <p class="text-2xl text-center md:text-sm tracking-[0.1em]">{{ Product.name }}</p>
  215.                                     </div>
  216.                                     {# カテゴリ #}
  217.                                     <p class="mx-auto w-fit px-3 whitespacenowrap text-sm py-1 border border-[#AFAFAF] text-center md:text-[8px] mt-3 mb-1 leading-normal">
  218.                                         {% if Category.id == 2 %}
  219.                                             お仏壇・ステージ
  220.                                         {% elseif Category.id == 3 %}
  221.                                             仏具・日用品
  222.                                         {% else %}
  223.                                             {{Category.name}}
  224.                                         {% endif %}
  225.                                     </p>
  226.                                     {# カラーコード #}
  227.                                     <div class="flex item-center flex-wrap justify-center gap-2 py-3">
  228.                                         {% for ProductClass in Product.ProductClasses %}
  229.                                             {# MEMO: Tailwindのbgクラスで変数展開ができなかった為、style属性を使ってスタイリングした #}
  230.                                             <span style="background-color: {{ ProductClass.color_code }};" class="w-4 h-4 rounded-[50%] md:w-2 md:h-2"></span>
  231.                                         {% endfor %}
  232.                                     </div>
  233.                                     <div>
  234.                                         {# 商品説明(一覧) #}
  235.                                         {% if Product.description_detail %}
  236.                                             <p class="text-center mb-4 md:text-xs md:mb-2 min-h-12 md:min-h-8 leading-normal tracking-[0.1em]">{{ Product.description_detail|raw|nl2br }}</p>
  237.                                         {% endif %}
  238.                                         {# 値段 #}
  239.                                         <p class="text-2xl text-center md:text-sm md:min-h-10 h-auto tracking-[0.1em]">
  240.                                             {% if Product.hasProductClass %}
  241.                                                 {% if Product.getPrice02Min == Product.getPrice02Max %}
  242.                                                     {{ Product.getPrice02IncTaxMin|number_format }}
  243.                                                 {% else %}
  244.                                                     {{ Product.getPrice02IncTaxMin|number_format }}
  245.                                                     ~
  246.                                                     {{ Product.getPrice02IncTaxMax|number_format }}
  247.                                                 {% endif %}
  248.                                             {% else %}
  249.                                                 {{ Product.getPrice02IncTaxMin|number_format }}
  250.                                             {% endif %}
  251.                                             <span class="text-xs md:text-[10px]">円(税込)</span>
  252.                                         </p>
  253.                                     </div>
  254.                                 </div>
  255.                             </div>
  256.                             {# フリーエリア #}
  257.                             {% if Product.free_area %}
  258.                                 <p class="free_area text-center px-10 py-3 bg-manakaBeige tracking-[0.2em] md:text-[10px] md:px-2 md:py-2 flex items-center justify-center mt-auto min-h-[72px]">
  259.                                     {{Product.free_area|raw|nl2br}}
  260.                                 </p>
  261.                             {% endif %}
  262.                         </a>
  263.                     </li>
  264.                 {% endfor %}
  265.             </ul>
  266.             </div>
  267.         </div>
  268.         {# ショールームのご案内 #}
  269.         <a href={{url( "user_data", { route : "showroom" })}} class="block my-16 mx-auto w-[840px] lg:w-[calc(100%-60px)] hover h-auto">
  270.             <img src="{{ asset('assets/img/list/showroom_pc.jpg') }}" class="shadow-lg lg:hidden"/>
  271.             <img src="{{ asset('assets/img/list/showroom_sp.jpg') }}" class="hidden lg:block max-h-[300px] shadow-lg  mx-auto"/>
  272.         </a>
  273.         {# 商品選びサポートサービス #}
  274.         <div class="flex flex-col  gap-10 md:gap-8 py-20 px-[104px] bg-manakaBeige w-full max-w-[1120px] xl:w-[calc(100%-60px)] mx-auto lg:px-5 lg:py-8">
  275.             <h3 class="text-[40px] text-center md:text-xl font-extralight">商品選びサポートサービス</h3>
  276.             <p class="text-xl text-center md:text-xs leading-relaxed">
  277.                 お客様と故人様の関係にふさわしい祈りのかたちを見つけていただくために、<br/>
  278.                 いくつかのサポートサービスをご用意しました。
  279.             </p>
  280.             <ul class="w-full flex gap-12 flex-wrap justify-center md:gap-5">
  281.                 <li class="w-[432px] xl:w-full hover">
  282.                     <a href={{url( "user_data", { route : "catalog" })}} class="w-full">
  283.                         <img src="{{ asset('assets/img/top/catalog-service.webp') }}" class="w-full"/>
  284.                     </a>
  285.                 </li>
  286.                 <li class="w-[432px] xl:w-full hover">
  287.                     <a href={{url('coordinate_confirm')}} class="w-full">
  288.                         <img src="{{ asset('assets/img/top/coordinate-service.webp') }}" class="w-full"/>
  289.                     </a>
  290.                 </li>
  291.                 <li class="w-[432px] xl:w-full hover">
  292.                     <a href={{url("user_data", {route:"pick_up_altar"})}} class="w-full">
  293.                         <img src="{{ asset('assets/img/top/takuover-service.webp') }}" class="w-full"/>
  294.                     </a>
  295.                 </li>
  296.             </ul>
  297.         </div>
  298.     {% endif %}
  299.     {% set breadcrumbs = [{'name': subtitle }] %}
  300.     {{ include('Block/breadcrumbs.twig') }}
  301. {% endblock %}