app/template/myTemplate/index.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 = 'front_page' %}
  10. {% block stylesheet %}
  11. <link rel="stylesheet" href="{{ asset('assets/css/top.css') }}" type="text/css" media="all" />
  12. {% endblock %}
  13. {% block javascript %}
  14.     <script>
  15.         eccube.productsClassCategories = {
  16.             {% for Product in pagination %}
  17.             "{{ Product.id|escape('js') }}": {{ class_categories_as_json(Product)|raw }}{% if loop.last == false %}, {% endif %}
  18.             {% endfor %}
  19.         };
  20.         $(function() {
  21.             // 表示件数を変更
  22.             $('.disp-number').change(function() {
  23.                 var dispNumber = $(this).val();
  24.                 $('#disp_number').val(dispNumber);
  25.                 $('#pageno').val(1);
  26.                 $("#form1").submit();
  27.             });
  28.             // 並び順を変更
  29.             $('.order-by').change(function() {
  30.                 var orderBy = $(this).val();
  31.                 $('#orderby').val(orderBy);
  32.                 $('#pageno').val(1);
  33.                 $("#form1").submit();
  34.             });
  35.             $('.add-cart').on('click', function(e) {
  36.                 var $form = $(this).parents('li').find('form');
  37.                 // 個数フォームのチェック
  38.                 var $quantity = $form.parent().find('.quantity');
  39.                 if ($quantity.val() < 1) {
  40.                     $quantity[0].setCustomValidity('{{ '1以上で入力してください。'|trans }}');
  41.                     setTimeout(function() {
  42.                         loadingOverlay('hide');
  43.                     }, 100);
  44.                     return true;
  45.                 } else {
  46.                     $quantity[0].setCustomValidity('');
  47.                 }
  48.                 e.preventDefault();
  49.                 $.ajax({
  50.                     url: $form.attr('action'),
  51.                     type: $form.attr('method'),
  52.                     data: $form.serialize(),
  53.                     dataType: 'json',
  54.                     beforeSend: function(xhr, settings) {
  55.                         // Buttonを無効にする
  56.                         $('.add-cart').prop('disabled', true);
  57.                     }
  58.                 }).done(function(data) {
  59.                     // レスポンス内のメッセージをalertで表示
  60.                     $.each(data.messages, function() {
  61.                         $('#ec-modal-header').text(this);
  62.                     });
  63.                     $('.ec-modal').show()
  64.                     // カートブロックを更新する
  65.                     $.ajax({
  66.                         url: '{{ url('block_cart') }}',
  67.                         type: 'GET',
  68.                         dataType: 'html'
  69.                     }).done(function(html) {
  70.                         $('.ec-headerRole__cart').html(html);
  71.                     });
  72.                 }).fail(function(data) {
  73.                     alert('{{ 'カートへの追加に失敗しました。'|trans }}');
  74.                 }).always(function(data) {
  75.                     // Buttonを有効にする
  76.                     $('.add-cart').prop('disabled', false);
  77.                 });
  78.             });
  79.         });
  80.         $('.ec-modal-wrap').on('click', function(e) {
  81.             // モーダル内の処理は外側にバブリングさせない
  82.             e.stopPropagation();
  83.         });
  84.         $('.ec-modal-overlay, .ec-modal, .ec-modal-close, .ec-inlineBtn--cancel').on('click', function() {
  85.             $('.ec-modal').hide()
  86.         });
  87.     </script>
  88. {% endblock javascript %}
  89. {% block main %}
  90. <main>
  91.     <section id="main-visual">
  92.         <div class="mainvisual" style="background-image: url('{{ asset('assets/img/common/mv_img_01.jpg') }}'); ?>)"></div>
  93.     </section>
  94.     <section id="main-title">
  95.         <h2 class="page-title">PRODUCTS</h2>
  96.         <div class="scroll">
  97.             <a href="#topic-path">
  98.                 <p>scroll</p>
  99.                 <img src="https://mx-build.jp/wp-content/themes/%E3%82%BF%E3%82%A4%E3%82%A8%E3%82%A4%E5%8C%97%E6%B5%B7%E9%81%93%E3%82%A8%E3%83%B3%E3%82%B7%E3%82%99%E3%83%8B%E3%82%A2%E3%82%A2%E3%83%AA%E3%83%B3%E3%82%AF%E3%82%99/img/scroll.png" alt="scroll-arrow">
  100.             </a>
  101.         </div>
  102.     </section>
  103.     <section id="topic-path">
  104.         <div class="wrapper">
  105.             <div class="container">
  106.                 <div class="page">
  107.                     <a href="/">
  108.                         <span class="home">HOME</span>
  109.                     </a>
  110.                     <span>&gt;</span>
  111.                     <span class="current">商品一覧</span>
  112.                 </div>
  113.             </div>
  114.         </div>
  115.     </section>
  116.     <!-- メニューバー -->
  117.     {% set Categories = repository('Eccube\\Entity\\Category').getList() %}
  118.     <section id="menu-bar">
  119.         <div class="wrapper">
  120.             <div class="container">
  121.                 <nav>
  122.                     <ul class="menu-list">
  123.                         {% for Category in Categories %}
  124.                             <li class="menu">
  125.                                 <a href="/shop/products/list?category_id={{ Category.id }}">{{ Category.name }}</a>
  126.                             </li>
  127.                         {% endfor %}
  128.                     </ul>
  129.                 </nav>
  130.             </div>
  131.         </div>
  132.     </section>
  133.     {% if search_form.category_id.vars.errors|length > 0 %}
  134.         <div class="ec-searchnavRole">
  135.             <p class="errormsg text-danger">{{ 'ご指定のカテゴリは存在しません'|trans }}</p>
  136.         </div>
  137.     {% else %}
  138.         <div class="ec-searchnavRole">
  139.             <form name="form1" id="form1" method="get" action="?">
  140.                 {% for item in search_form %}
  141.                     <input type="hidden" id="{{ item.vars.id }}"
  142.                            name="{{ item.vars.full_name }}"
  143.                            {% if item.vars.value is not empty %}value="{{ item.vars.value }}" {% endif %}/>
  144.                 {% endfor %}
  145.             </form>
  146.             <div class="ec-searchnavRole__infos">
  147.                 <div class="ec-searchnavRole__counter">
  148.                     {% if pagination.totalItemCount > 0 %}
  149.                         {{ '<span class="ec-font-bold">%count%件</span><span>の商品が見つかりました</span>'|trans({ '%count%': pagination.totalItemCount })|raw }}
  150.                     {% else %}
  151.                         <span>{{ 'お探しの商品は見つかりませんでした'|trans }}</span>
  152.                     {% endif %}
  153.                 </div>
  154.                 {% if pagination.totalItemCount > 0 %}
  155.                     <div class="ec-searchnavRole__actions">
  156.                         <div class="ec-select">
  157.                             {{ form_widget(search_form.disp_number, {'id': '', 'attr': {'class': 'disp-number'}}) }}
  158.                             {{ form_widget(search_form.orderby, {'id': '', 'attr': {'class': 'order-by'}}) }}
  159.                         </div>
  160.                     </div>
  161.                 {% endif %}
  162.             </div>
  163.         </div>
  164.         {% if pagination.totalItemCount > 0 %}
  165.             <div class="ec-shelfRole">
  166.                 <ul class="ec-shelfGrid">
  167.                     {% for Product in pagination %}
  168.                         <li class="ec-shelfGrid__item">
  169.                             <a href="{{ url('product_detail', {'id': Product.id}) }}">
  170.                                 <div class="ec-shelfGrid__item-image"><div style="background-image: url({{ asset(Product.main_list_image|no_image_product, 'save_image') }});"></div></div>
  171.                                 <!--
  172.                                 <p class="ec-shelfGrid__item-image">
  173.                                     <img src="{{ asset(Product.main_list_image|no_image_product, 'save_image') }}" alt="{{ Product.name }}" {% if loop.index > 5 %} loading="lazy"{% endif %}>
  174.                                 </p>
  175.                                 -->
  176.                                 <div class="myTemplate-item-header">
  177.                                     <p>{{ Product.name }}</p>
  178.                                     {% if Product.description_list %}
  179.                                         <p>{{ Product.description_list|raw|nl2br }}</p>
  180.                                     {% endif %}
  181.                                     <p class="price02-default">
  182.                                         {% if Product.hasProductClass %}
  183.                                             {% if Product.getPrice02Min == Product.getPrice02Max %}
  184.                                                 {{ Product.getPrice02IncTaxMin|price }}
  185.                                             {% else %}
  186.                                                 {{ Product.getPrice02IncTaxMin|price }} ~ {{ Product.getPrice02IncTaxMax|price }}
  187.                                             {% endif %}
  188.                                         {% else %}
  189.                                             {{ Product.getPrice02IncTaxMin|price }}
  190.                                         {% endif %}
  191.                                     </p>
  192.                                 </div>
  193.                             </a>
  194.                             {% if Product.stock_find %}
  195.                                 {% set form = forms[Product.id] %}
  196.                                 <form name="form{{ Product.id }}" id="productForm{{ Product.id }}" action="{{ url('product_add_cart', {id:Product.id}) }}" method="post">
  197.                                     <div class="ec-productRole__actions">
  198.                                         {% if form.classcategory_id1 is defined %}
  199.                                             <div class="ec-select">
  200.                                                 <span>{{ form.classcategory_id1.vars['label'] }}</span>
  201.                                                 {{ form_widget(form.classcategory_id1) }}
  202.                                                 {{ form_errors(form.classcategory_id1) }}
  203.                                             </div>
  204.                                             {% if form.classcategory_id2 is defined %}
  205.                                                 <div class="ec-select">
  206.                                                     <span>{{ form.classcategory_id2.vars['label'] }}</span>
  207.                                                     {{ form_widget(form.classcategory_id2) }}
  208.                                                     {{ form_errors(form.classcategory_id2) }}
  209.                                                 </div>
  210.                                             {% endif %}
  211.                                         {% endif %}
  212.                                         <div class="myTemplate-ec-numberInput">
  213.                                             <span>{{ '数量'|trans }}</span>
  214.                                             {{ form_widget(form.quantity, {'attr': {'class': 'quantity'}}) }}
  215.                                             {{ form_errors(form.quantity) }}
  216.                                         </div>
  217.                                         <div class="myTemplate-options">
  218.                                             {{ form_rest(form) }}
  219.                                         </div>
  220.                                     </div>
  221.                                 </form>
  222.                                 <div class="ec-productRole__btn">
  223.                                     <button type="submit" class="ec-blockBtn--action add-cart" data-cartid="{{ Product.id }}" form="productForm{{ Product.id }}">
  224.                                         {{ 'カートに入れる'|trans }}
  225.                                     </button>
  226.                                 </div>
  227.                             {% else %}
  228.                                 <div class="ec-productRole__btn">
  229.                                     <button type="button" class="ec-blockBtn--action" disabled="disabled">
  230.                                         {{ 'ただいま品切れ中です。'|trans }}
  231.                                     </button>
  232.                                 </div>
  233.                             {% endif %}
  234.                         </li>
  235.                     {% endfor %}
  236.                 </ul>
  237.             </div>
  238.             <div class="ec-modal">
  239.                 <div class="ec-modal-overlay">
  240.                     <div class="ec-modal-wrap">
  241.                         <span class="ec-modal-close"><span class="ec-icon"><img src="{{ asset('assets/icon/cross-dark.svg') }}" alt=""/></span></span>
  242.                         <div id="ec-modal-header" class="text-center">{{ 'カートに追加しました。'|trans }}</div>
  243.                         <div class="ec-modal-box">
  244.                             <div class="ec-role">
  245.                                 <span class="ec-inlineBtn--cancel">{{ 'お買い物を続ける'|trans }}</span>
  246.                                 <a href="{{ url('cart') }}" class="ec-inlineBtn--action">{{ 'カートへ進む'|trans }}</a>
  247.                             </div>
  248.                         </div>
  249.                     </div>
  250.                 </div>
  251.             </div>
  252.             <div class="ec-pagerRole">
  253.                 {% include "pager.twig" with {'pages': pagination.paginationData} %}
  254.             </div>
  255.         {% endif %}
  256.     {% endif %}
  257. </main>
  258. {% endblock %}