app/Plugin/SDream/Resource/template/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. {% set current_category = null %}
  88. {#
  89. <div>
  90. {{CategorySelf.id}} {{CategorySelf.name}} {{CategorySelf.category_picfilename}}
  91. {% for cat in CategoryList %}
  92.     <div class="catinfo">
  93.         {{cat.id}} {{cat.name}} {{cat.category_picfilename}}
  94.     </div>
  95. {% endfor %}
  96. </div>
  97. #}
  98. {#
  99. カテゴリを一覧で一気に表示する
  100. {% if Category !=null and Category.id != null and Category.id == '21' %}
  101. <div>
  102.     {% for product in Category21Products %}
  103.         {% if current_category != product.category_name %}
  104.             {% set current_category = product.category_name %}
  105.             <div class="category-header">
  106.                 <a href="{{ url('product_list') }}?category_id={{ product.category_id }}">{{ current_category }}</a>
  107.             </div>
  108.         {% endif %}
  109.         <div class="product-item">
  110.             ・<a href="{{ url('product_detail', {'id': product.product_id}) }}">
  111.                 {{ product.product_name }}
  112.             </a>
  113.         </div>
  114.     {% endfor %}
  115. </div>
  116. {% endif %}
  117. <style>
  118.     .category-header {
  119.         width: 100%;
  120.         border: 1px solid #000; /* 線の色とスタイルを指定 */
  121.         padding: 10px;          /* 内側の余白を指定 */
  122.         box-sizing: border-box; /* ボックスのサイズを含む */
  123.         background-color: #f8f8f8; /* 背景色を指定(任意) */
  124.         font-weight: bold;      /* フォントを太字にする(任意) */
  125.         margin-bottom: 10px;    /* 下部の余白を指定(任意) */
  126.     }
  127.     .product-item {
  128.         margin-left: 20px;      /* 商品名を少しインデントする(任意) */
  129.     }
  130. </style>
  131. #}
  132.     {% if search_form.category_id.vars.errors|length > 0 %}
  133.         <div class="ec-searchnavRole">
  134.             <p class="errormsg text-danger">{{ 'ご指定のカテゴリは存在しません'|trans }}</p>
  135.         </div>
  136.     {% else %}
  137.         <div class="ec-searchnavRole">
  138.             <form name="form1" id="form1" method="get" action="?">
  139.                 {% for item in search_form %}
  140.                     <input type="hidden" id="{{ item.vars.id }}"
  141.                            name="{{ item.vars.full_name }}"
  142.                            {% if item.vars.value is not empty %}value="{{ item.vars.value }}" {% endif %}/>
  143.                 {% endfor %}
  144.             </form>
  145. <div class="catimgself">
  146.     {% if CategorySelf is not empty and CategorySelf.category_picfilename is not empty %}
  147.         <img src="{{ asset(CategorySelf.category_picfilename) }}" alt="{{ CategorySelf.category_picalt }}" />
  148.     {% endif %}
  149.     <div class="catimgchild-container">
  150.         {% if CategoryList is not empty %}
  151.             {% for cat in CategoryList %}
  152.                 {% if cat is not empty and cat.category_minipicfilename is not empty and (cat.category_enable is empty or cat.category_enable != '1') %}
  153.                     <div class="catimgchild">
  154.                         <a href="{{ url('product_list') }}?category_id={{ cat.id }}">
  155.                             <img src="{{ asset(cat.category_minipicfilename) }}" alt="{{ cat.category_picalt }}"  />
  156.                         </a>
  157.                     </div>
  158.                 {% endif %}
  159.             {% endfor %}
  160.         {% endif %}
  161.     </div>
  162. </div>
  163. <style>
  164. .catimgself {
  165.     display: flex;
  166.     flex-direction: column;
  167.     align-items: center;
  168. }
  169. .catimgself img {
  170.     max-width: 100%;
  171.     height: auto;
  172. }
  173. .catimgchild-container {
  174.     display: flex;
  175.     flex-wrap: wrap;
  176.     justify-content: space-between;
  177.     margin: 0; /* 親コンテナのマージンをリセット */
  178. }
  179. .catimgchild {
  180.     flex: 1 0 33.33%; /* 子要素を3列に分けるために幅を調整 */
  181.     max-width: 33.33%; /* 子要素の最大幅を設定 */
  182.     text-align: center;
  183.     margin: 0; /* 子要素間の間隔をなくす */
  184.     box-sizing: border-box; /* パディングとボーダーを含めて要素のサイズを計算 */
  185. }
  186. .catimgchild img {
  187.     width: 100%;
  188.     height: auto;
  189. }
  190. </style>
  191.             {#
  192.             {% if Category is not null %}
  193.                 {% for Path in Category.path %}
  194.                     {% if loop.last %}
  195.                         {% if Path.id=='21' %}
  196.                             <div class="selectedmenu"><img src="{{ asset('/img/category/cornerbanner/21.jpg') }}" /></div>
  197.                         {% elseif Path.id=='22' %}
  198.                             <div class="selectedmenu"><img src="{{ asset('/img/category/cornerbanner/22.jpg') }}" /></div>
  199.                         {% elseif Path.id=='24' %}
  200.                             <div class="selectedmenu"><img src="{{ asset('/img/category/cornerbanner/24.jpg') }}" /></div>   
  201.                         {% elseif Path.id=='25' %}
  202.                             <div class="selectedmenu"><img src="{{ asset('/img/category/cornerbanner/25.jpg') }}" /></div>      
  203.                         {% elseif Path.id=='26' %}
  204.                             <div class="selectedmenu"><img src="{{ asset('/img/category/cornerbanner/26.jpg') }}" /></div>       
  205.                         {% elseif Path.id=='27' %}
  206.                             <div class="selectedmenu"><img src="{{ asset('/img/category/cornerbanner/27.jpg') }}" /></div>                  
  207.                         {% elseif Path.id=='28' %}
  208.                             <div class="selectedmenu"><img src="{{ asset('/img/category/cornerbanner/28.jpg') }}" /></div>   
  209.                         {% elseif Path.id=='76' or Path.id=='77' or Path.id=='78' or Path.id=='79' or Path.id=='81' or Path.id=='80' or Path.id=='83' or Path.id=='86' %}
  210.                             <div class="selectedmenu">「 お米の産地別 」を選択中</div>
  211.                         {% elseif Path.id=='66' or Path.id=='67' or Path.id=='68' or Path.id=='69' or Path.id=='70' or Path.id=='71' %}
  212.                             <div class="selectedmenu">「 お米の銘柄別 」を選択中</div>
  213.                         {% elseif Path.id=='41' or Path.id=='42' or Path.id=='43' %}
  214.                             <div class="selectedmenu">「 価格帯ごと 」を選択中</div>
  215.                         {% elseif Path.id=='58' or Path.id=='59' or Path.id=='60' %}
  216.                             <div class="selectedmenu">「 粒サイズ 」を選択中</div>
  217.                         {% elseif Path.id=='49' or Path.id=='50' or Path.id=='51' or Path.id=='52' %}
  218.                             <div class="selectedmenu">「 ロットサイズ 」を選択中</div>
  219.                         {% elseif Path.id=='116' or Path.id=='117' or Path.id=='117' %}
  220.                             <div class="selectedmenu">「 精米レベル 」を選択中</div>
  221.                         {% elseif Path.id=='10' %}
  222.                             <div class="selectedmenu">「 産直品コーナー 」を選択中</div>
  223.                         {% elseif Path.id=='12' %}
  224.                             <div class="selectedmenu">「 産直 畜産品市場 」を選択中</div>
  225.                         {% elseif Path.id=='13' %}
  226.                             <div class="selectedmenu">「 産直 水産市場 」を選択中</div>
  227.                         {% elseif Path.id=='14' %}
  228.                             <div class="selectedmenu">「 産直 農産品市場 」を選択中</div>
  229.                         {% elseif Path.id=='15' %}
  230.                             <div class="selectedmenu">「 産直 加工食品市場 」を選択中</div>
  231.                         {% elseif Path.id=='19' %}
  232.                             <div class="selectedmenu">「 産直 訳アリB級品 」を選択中</div>
  233.                         {% else %}
  234.                             <div class="selectedmenu">「 {{ Path.name }} 」を選択中</div>
  235.                         {% endif %}
  236.                     {% endif %}
  237.                 {% endfor %}
  238.             {% endif %}
  239.             #}
  240.             <div class="ec-searchnavRole__topicpath">
  241.                 <ol class="ec-topicpath">
  242.                     <li class="ec-topicpath__item"><a href="{{ url('product_list') }}">{{ '全て'|trans }}</a>
  243.                     </li>
  244.                     {% if Category is not null %}
  245.                         {% for Path in Category.path %}
  246.                             <li class="ec-topicpath__divider">|</li>
  247.                             
  248.                             
  249.                                 <li class="ec-topicpath__item{% if loop.last %}--active{% endif %}">
  250.                                     <a href="{{ url('product_list') }}?category_id={{ Path.id }}">{{ Path.name }}</a>
  251.                                     {% if Path.name == '産地で選ぶ' %}
  252.                                         |<a href="/products/list?category_id=76">北海道</a>
  253.                                         |<a href="/products/list?category_id=77">東北</a>
  254.                                         |<a href="/products/list?category_id=78">関東</a>
  255.                                         |<a href="/products/list?category_id=79">信越</a>
  256.                                         |<a href="/products/list?category_id=81">北陸</a>
  257.                                         |<a href="/products/list?category_id=80">中部</a>
  258.                                         |<a href="/products/list?category_id=83">西日本</a>
  259.                                         |<a href="/products/list?category_id=86">国内</a>
  260.                                     {% elseif Path.name == '銘柄で選ぶ' %}
  261.                                         |<a href="/products/list?category_id=66">コシヒカリ</a>
  262.                                         |<a href="/products/list?category_id=67">ひとめぼれ</a>
  263.                                         |<a href="/products/list?category_id=68">あきたこまち</a>
  264.                                         |<a href="/products/list?category_id=69">各他の銘柄</a>
  265.                                         |<a href="/products/list?category_id=70">逸品米</a>
  266.                                         |<a href="/products/list?category_id=71">無洗米</a>
  267.                                     {% elseif Path.name == '価格帯で選ぶ' %}
  268.                                         |<a href="/products/list?category_id=41">299円以下</a>
  269.                                         |<a href="/products/list?category_id=42">239円以下</a>
  270.                                         |<a href="/products/list?category_id=43">329円以上</a>
  271.                                     {% elseif Path.name == '粒サイズで選ぶ' %}
  272.                                         |<a href="/products/list?category_id=58">通常</a>
  273.                                         |<a href="/products/list?category_id=59">やや小粒</a>
  274.                                         |<a href="/products/list?category_id=60">ブレンド</a>
  275.                                     {% elseif Path.name == 'ロットサイズで選ぶ' %}
  276.                                         |<a href="/products/list?category_id=49">小ロット</a>
  277.                                         <a href="/products/list?category_id=50">業務用</a>
  278.                                         |<a href="/products/list?category_id=51">大口割引</a>
  279.                                         |<a href="/products/list?category_id=52">激安</a>
  280.                                     {% elseif Path.name == '精米方法で選ぶ' %}
  281.                                         |<a href="/products/list?category_id=116">上白精米</a>
  282.                                         |<a href="/products/list?category_id=117">精白米</a>
  283.                                         |<a href="/products/list?category_id=118">玄米</a>
  284.                                     {% endif %}
  285.                                 </li>
  286.                         {% endfor %}
  287.                     {% endif %}
  288.                     {% if search_form.vars.value and search_form.vars.value.name %}
  289.                         <li class="ec-topicpath__divider">|</li>
  290.                         <li class="ec-topicpath__item">{{ '「%name%」の検索結果'|trans({ '%name%': search_form.vars.value.name }) }}</li>
  291.                     {% endif %}
  292.                 </ol>
  293.             </div>
  294.             <div class="ec-searchnavRole__infos">
  295.                 <div class="ec-searchnavRole__counter">
  296.                     {% if pagination.totalItemCount > 0 %}
  297.                         {{ '<span class="ec-font-bold">%count%件</span><span>の商品が見つかりました</span>'|trans({ '%count%': pagination.totalItemCount })|raw }}
  298.                     {% else %}
  299.                         <span>{{ 'お探しの商品は見つかりませんでした'|trans }}</span>
  300.                     {% endif %}
  301.                 </div>
  302.                 {% if pagination.totalItemCount > 0 %}
  303.                     <div class="ec-searchnavRole__actions">
  304.                         <div class="ec-select">
  305.                             {{ form_widget(search_form.disp_number, {'id': '', 'attr': {'class': 'disp-number'}}) }}
  306.                             {{ form_widget(search_form.orderby, {'id': '', 'attr': {'class': 'order-by'}}) }}
  307.                         </div>
  308.                     </div>
  309.                 {% endif %}
  310.             </div>
  311.         </div>
  312.         <div id="flash-area"></div>
  313.         {% if pagination.totalItemCount > 0 %}
  314.             <div class="ec-shelfRole">
  315.                 <ul class="ec-shelfGrid">
  316.                     {% for Product in pagination %}                        
  317.                         {% if Product.limited_ids == '' %}
  318.                             <li class="ec-shelfGrid__item">
  319.                             <a href="{{ url('product_detail', {'id': Product.id}) }}">
  320.                                 <p class="ec-shelfGrid__item-image">
  321. {# === SDR === #}
  322. {% if eccube_config.app_mode != 'display' %}
  323.     {% set image_url = asset(Product.main_list_image, 'save_image') %}
  324. {% elseif Product.mainDisplayImage %}
  325.     {% set image_url = eccube_config.img_folder ~ Product.mainDisplayImage.fileName %}
  326. {% endif %}
  327. {% if image_url is defined %}
  328.     <img src="{{ image_url }}" alt="{{ Product.name }}" {% if loop.index > 5 %}loading="lazy"{% endif %}>
  329. {% else %}
  330.     <div class="ec-shelfGrid__item-noimage">
  331.         ★画像準備中
  332.     </div>
  333. {% endif %}
  334. {# === SDR === #}
  335.                                 </p>
  336.                                 <p>{{ Product.name }}</p>
  337.                                 {% if Product.description_list %}
  338.                                     <p>{{ Product.description_list|raw|nl2br }}</p>
  339.                                 {% endif %}
  340.                                 <p class="price02-default">
  341. {# === SDR === #}
  342. {% if eccube_config.app_mode != 'display' %}
  343.                                     {% if Product.hasProductClass %}
  344.                                         {% if Product.getPrice02IncTaxMin == Product.getPrice02IncTaxMax %}
  345.                                             {{ Product.getPrice02IncTaxMin|price }}
  346.                                         {% else %}
  347.                                             {{ Product.getPrice02IncTaxMin|price }} ~ {{ Product.getPrice02IncTaxMax|price }}
  348.                                         {% endif %}
  349.                                     {% else %}
  350.                                         {{ Product.getPrice02IncTaxMin|price }}
  351.                                     {% endif %}
  352. {% else %}
  353. {#規格あり・規格なしに関係なく、表示対象の ProductClass から価格を取得#}
  354.                                     {% if Product.getPriceSellerInTaxMin == Product.getPriceSellerInTaxMax %}
  355.                                         {{ Product.getPriceSellerInTaxMin|price }}
  356.                                     {% else %}
  357.                                         {{ Product.getPriceSellerInTaxMin|price }} ~ {{ Product.getPriceSellerInTaxMax|price }}
  358.                                     {% endif %}
  359. {% endif %}
  360.                                 </p>
  361.                             </a>
  362. {# === SDR === #}
  363. {% if eccube_config.app_mode != 'display' %}
  364.                             {% if Product.stock_find %}
  365.                                 {% if Product.locked_ids is not empty %}  
  366.                                     <br>                              
  367.                                     <button type="button" class="ec-blockBtn--action add-cart" data-cartid="{{ Product.id }}" onclick="submitFormAndRedirect('{{ Product.id }}', '{{ url('product_detail', {'id': Product.id}) }}')">
  368.                                         {{ '詳細表示'|trans }}
  369.                                     </button>
  370.                                     
  371.                                 {% else %}
  372.                                     {% set form = forms[Product.id] %}
  373.                                     <form name="form{{ Product.id }}" id="productForm{{ Product.id }}" action="{{ url('product_add_cart', {id:Product.id}) }}" method="post">
  374.                                         <div class="ec-productRole__actions">
  375.                                             {% if form.classcategory_id1 is defined %}
  376.                                                 <div class="ec-select">
  377.                                                     {{ form_widget(form.classcategory_id1) }}
  378.                                                     {{ form_errors(form.classcategory_id1) }}
  379.                                                 </div>
  380.                                                 {% if form.classcategory_id2 is defined %}
  381.                                                     <div class="ec-select">
  382.                                                         {{ form_widget(form.classcategory_id2) }}
  383.                                                         {{ form_errors(form.classcategory_id2) }}
  384.                                                     </div>
  385.                                                 {% endif %}
  386.                                             {% endif %}
  387.                                             <div class="ec-numberInput"><span>{{ '数量'|trans }}</span>
  388.                                                 {{ form_widget(form.quantity, {'attr': {'class': 'quantity'}}) }}
  389.                                                 {{ form_errors(form.quantity) }}
  390.                                             </div>
  391.                                         </div>
  392.                                         {{ form_rest(form) }}
  393.                                     </form>
  394.                                     <div class="ec-productRole__btn">
  395.                                         
  396.                                         <button type="submit" class="ec-blockBtn--action add-cart" data-cartid="{{ Product.id }}" form="productForm{{ Product.id }}">
  397.                                             {{ 'カートに入れる'|trans }}
  398.                                         </button>
  399.                                     </div>
  400.                                 {% endif %}
  401.                             {% else %}
  402.                                 <div class="ec-productRole__btn">
  403.                                     <button type="button" class="ec-blockBtn--action" disabled="disabled">
  404.                                         {{ 'ただいま品切れ中です。'|trans }}
  405.                                     </button>
  406.                                 </div>
  407.                             {% endif %}
  408. {% endif %}
  409. {# === SDR === #}
  410.                             </li>
  411.                         {% endif %}
  412.                     {% endfor %}
  413.                 </ul>
  414.             </div>
  415.             <div class="ec-modal">
  416.                 <div class="ec-modal-overlay">
  417.                     <div class="ec-modal-wrap">
  418.                         <span class="ec-modal-close"><span class="ec-icon"><img src="{{ asset('assets/icon/cross-dark.svg') }}" alt=""/></span></span>
  419.                         <div id="ec-modal-header" class="text-center">{{ 'カートに追加しました。'|trans }}</div>
  420.                         <div class="ec-modal-box">
  421.                             <div class="ec-role">
  422.                                 <span class="ec-inlineBtn--cancel">{{ 'お買い物を続ける'|trans }}</span>
  423.                                 <a href="{{ url('cart') }}" class="ec-inlineBtn--action">{{ 'カートへ進む'|trans }}</a>
  424.                             </div>
  425.                         </div>
  426.                     </div>
  427.                 </div>
  428.             </div>
  429.             <div class="ec-pagerRole">
  430.                 {% include "pager.twig" with {'pages': pagination.paginationData} %}
  431.             </div>
  432.         {% endif %}
  433.     {% endif %}
  434. <style>
  435.     .selectedmenu {
  436.         height: 35px;
  437.         margin: 20px;
  438.         border: 0px solid;
  439.         background-color: #F0FFF0;
  440.         display: flex;
  441.         align-items: center;
  442.         justify-content: center; /* 水平方向にも中央揃えする場合 */
  443.         
  444.     }
  445.     .selectedmenu img {
  446.         /*height: 50%;*/
  447.     }
  448. </style>
  449. <script>
  450.     function submitFormAndRedirect(productId, url) {
  451.         window.location.href = url;
  452.     }
  453. </script>
  454. <style>
  455.     .custom-flash {
  456.         border: 2px solid #e60000;   /* 赤い枠 */
  457.         background-color: #ffe6e6;   /* 薄いピンク背景 */
  458.         color: #900;                 /* 赤系文字色 */
  459.         padding: 12px 16px;
  460.         border-radius: 4px;
  461.         margin-bottom: 10px;
  462.         font-weight: bold;
  463.     }
  464. </style>
  465. {% endblock %}