app/template/meldiastore/Product/list.twig line 1

Open in your IDE?
  1. {#
  2. This file is part of EC-CUBE
  3. Copyright(c) LOCKON CO.,LTD. All Rights Reserved.
  4. http://www.lockon.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 stylesheet %}
  11. <style>
  12.     .p-product__title-text {
  13.     color: #807245;
  14. }
  15. .c-button--unelevated.is-secondary {
  16.     background-color: #807245;
  17. }
  18. </style>
  19. {% endblock %}
  20. {% block javascript %}
  21.     <script src="{{ asset('assets/js/eccube.js') }}"></script>
  22.     <script>
  23.         eccube.productsClassCategories = {
  24.             {% for Product in pagination %}
  25.                 "{{ Product.id|escape('js') }}": {{ class_categories_as_json(Product)|raw }}{% if loop.last == false %}, {% endif %}
  26.             {% endfor %}
  27.         };
  28.         $(function() {
  29.             // 表示件数を変更
  30.             $('.disp-number').change(function() {
  31.                 var dispNumber = $(this).val();
  32.                 $('#disp_number').val(dispNumber);
  33.                 $('#pageno').val(1);
  34.                 $("#form1").submit();
  35.             });
  36.             // 並び順を変更
  37.             $('.order-by').change(function() {
  38.                 var orderBy = $(this).val();
  39.                 $('#orderby').val(orderBy);
  40.                 $('#pageno').val(1);
  41.                 $("#form1").submit();
  42.             });
  43.             $('.add-cart').on('click', function(e) {
  44.                 var $form = $(this).parents('li').find('form');
  45.                 // 個数フォームのチェック
  46.                 var $quantity = $form.parent().find('.quantity');
  47.                 if ($quantity.val() < 1) {
  48.                     $quantity[0].setCustomValidity('{{ '1以上で入力してください。'|trans }}');
  49.                     setTimeout(function() {
  50.                         loadingOverlay('hide');
  51.                     }, 100);
  52.                     return true;
  53.                 } else {
  54.                     $quantity[0].setCustomValidity('');
  55.                 }
  56.                 e.preventDefault();
  57.                 $.ajax({
  58.                     url: $form.attr('action'),
  59.                     type: $form.attr('method'),
  60.                     data: $form.serialize(),
  61.                     dataType: 'json',
  62.                     beforeSend: function(xhr, settings) {
  63.                         // Buttonを無効にする
  64.                         $('.add-cart').prop('disabled', true);
  65.                     }
  66.                 }).done(function(data) {
  67.                     // レスポンス内のメッセージをalertで表示
  68.                     $.each(data.messages, function() {
  69.                         $('#js-product__modal-message').html(this);
  70.                     });
  71.                     $('#p-product__modal-checkbox').prop('checked', true);
  72.                     // カートブロックを更新する
  73.                     $.ajax({
  74.                         url: '{{ url('block_cart') }}',
  75.                         type: 'GET',
  76.                         dataType: 'html'
  77.                     }).done(function(html) {
  78.                         $('#js-header__utility-cart').html(html);
  79.                     });
  80.                 }).fail(function(data) {
  81.                     alert('{{ 'カートへの追加に失敗しました。'|trans }}');
  82.                 }).always(function(data) {
  83.                     // Buttonを有効にする
  84.                     $('.add-cart').prop('disabled', false);
  85.                 });
  86.             });
  87.         });
  88.     </script>
  89. {% endblock %}
  90. {% block main %}
  91.     <section class="p-product">
  92.         <h2 class="p-product__title">
  93.             {% if search_form.vars.value and search_form.vars.value.name %}
  94.                 <span class="p-product__title-text">KEYWORD SEARCH</span>
  95.             {% elseif Category is not null %}
  96.                 <span class="p-product__title-text">PRODUCT</span>
  97.             {% else %}
  98.                 <span class="p-product__title-text">ALL PRODUCT</span>
  99.             {% endif %}
  100.         </h2>
  101.         <div class="p-product__contents">
  102.             {% if search_form.category_id.vars.errors|length > 0 %}
  103.                 <p>{{ 'ご指定のカテゴリは存在しません'|trans }}</p>
  104.             {% else %}
  105.                 <div class="p-product__search">
  106.                     <form name="form1" id="form1" method="get" action="?">
  107.                         {% for item in search_form %}
  108.                             <input type="hidden" id="{{ item.vars.id }}" name="{{ item.vars.full_name }}" {% if item.vars.value is not empty %}value="{{ item.vars.value }}" {% endif %}/>
  109.                         {% endfor %}
  110.                     </form>
  111.                     <div class="p-product__topicpath">
  112.                         <ul class="p-product__topicpath-list u-list-sanitize">
  113.                             <li class="p-product__topicpath-list-item">
  114.                                 <a class="p-product__topicpath-link" href="{{ url('product_list') }}">{{ '全て'|trans }}</a>
  115.                             </li>
  116.                             {% if Category is not null %}
  117.                                 {% for Path in Category.path %}
  118.                                     <li class="p-product__topicpath-list-item{% if loop.last %} is-active{% endif %}">
  119.                                         <a class="p-product__topicpath-link" href="{{ url('product_list') }}?category_id={{ Path.id }}">{{ Path.name }}</a>
  120.                                     </li>
  121.                                 {% endfor %}
  122.                             {% endif %}
  123.                             {% if search_form.vars.value and search_form.vars.value.name %}
  124.                                 <li class="p-product__topicpath-list-item is-result">
  125.                                     <p class="p-product__topicpath-result">{{ '%name%の検索結果'|trans({ '%name%': search_form.vars.value.name }) }}</p>
  126.                                 </li>
  127.                             {% endif %}
  128.                         </ul>
  129.                     </div>
  130.                     <div class="p-product__controller">
  131.                         <p class="p-product__controller-result">
  132.                             {% if pagination.totalItemCount > 0 %}
  133.                                 {{ '<span class="p-product__controller-result--number">%count%件</span><span class="p-product__controller-result--text">の商品が見つかりました</span>'|trans({ '%count%': pagination.totalItemCount })|raw }}
  134.                             {% else %}
  135.                                 <span class="p-product__controller-result--text">{{ 'お探しの商品は見つかりませんでした'|trans }}</span>
  136.                             {% endif %}
  137.                         </p>
  138.                         {% if pagination.totalItemCount > 0 %}
  139.                             <div class="p-product__controller-actions">
  140.                                 <div class="p-product__controller-actions-item">
  141.                                     <div class="c-select mdc-select mdc-select--outlined">
  142.                                         <i class="mdc-select__dropdown-icon"></i>
  143.                                         <label class="c-select__label" for="disp-number">件数</label>
  144.                                         {{ form_widget(disp_number_form, {'id': 'disp-number', 'attr': {'class': 'c-select__native-control mdc-select__native-control disp-number'}}) }}
  145.                                         <div class="mdc-notched-outline">
  146.                                             <div class="mdc-notched-outline__leading"></div>
  147.                                             <div class="mdc-notched-outline__notch"></div>
  148.                                             <div class="mdc-notched-outline__trailing"></div>
  149.                                         </div>
  150.                                     </div>
  151.                                 </div>
  152.                                 <div class="p-product__controller-actions-item">
  153.                                     <div class="c-select mdc-select mdc-select--outlined">
  154.                                         <i class="mdc-select__dropdown-icon"></i>
  155.                                         <label class="c-select__label" for="order-by">並び順</label>
  156.                                         {{ form_widget(order_by_form, {'id': 'order-by', 'attr': {'class': 'c-select__native-control mdc-select__native-control order-by'}}) }}
  157.                                         <div class="mdc-notched-outline">
  158.                                             <div class="mdc-notched-outline__leading"></div>
  159.                                             <div class="mdc-notched-outline__notch"></div>
  160.                                             <div class="mdc-notched-outline__trailing"></div>
  161.                                         </div>
  162.                                     </div>
  163.                                 </div>
  164.                             </div>
  165.                         {% endif %}
  166.                     </div>
  167.                 </div>
  168.                 {% if pagination.totalItemCount > 0 %}
  169.                     <ul class="p-product__list u-list-sanitize">
  170.                         {% for Product in pagination %}
  171.                             <li class="p-product__list-item">
  172.                                 <section class="c-list-product">
  173.                                     <a class="c-list-product__link" href="{{ url('product_detail', {'id': Product.id}) }}">
  174.                                         <div class="c-list-product__image js-list-product__image">
  175.                                             <div class="c-list-product__image-contents">
  176.                                                 <img class="c-list-product__image-pic" src="{{ asset(Product.main_list_image|no_image_product, 'save_image') }}" alt="{{ Product.name }}">
  177.                                             </div>
  178.                                         </div>
  179.                                         <h2 class="c-list-product__name js-list-product__name">{{ Product.name }}</h2>
  180.                                         <p class="c-list-product__price">
  181.                                             <span 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.                                             </span>
  192.                                         </p>
  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="c-list-product__form">
  198.                                                 {% if form.classcategory_id1 is defined %}
  199.                                                     <div class="c-list-product__form-box">
  200.                                                         <div class="c-list-product__form-box-item">
  201.                                                             <div class="c-select mdc-select mdc-select--outlined{{ has_errors(form.classcategory_id1) ? ' mdc-select--invalid' }}">
  202.                                                                 <i class="mdc-select__dropdown-icon"></i>
  203.                                                                 <label class="c-select__label" for="{{ form.children.classcategory_id1.vars.id }}">{{ form.children.classcategory_id1.vars.label }}</label>
  204.                                                                 {{ form_widget(form.classcategory_id1, { 'attr': {'class': 'c-select__native-control mdc-select__native-control' }}) }}
  205.                                                                 <div class="mdc-notched-outline">
  206.                                                                     <div class="mdc-notched-outline__leading"></div>
  207.                                                                     <div class="mdc-notched-outline__notch"></div>
  208.                                                                     <div class="mdc-notched-outline__trailing"></div>
  209.                                                                 </div>
  210.                                                             </div>
  211.                                                             {{ form_errors(form.classcategory_id1, {'label_attr': {'class': 'mdc-select-helper-text mdc-select-helper-text--validation-msg'}}) }}
  212.                                                         </div>
  213.                                                     </div>
  214.                                                     {% if form.classcategory_id2 is defined %}
  215.                                                         <div class="c-list-product__form-box">
  216.                                                             <div class="c-list-product__form-box-item">
  217.                                                                 <div class="c-select mdc-select mdc-select--outlined{{ has_errors(form.classcategory_id2) ? ' mdc-select--invalid' }}">
  218.                                                                     <i class="mdc-select__dropdown-icon"></i>
  219.                                                                     <label class="c-select__label" for="{{ form.children.classcategory_id2.vars.id }}">{{ form.children.classcategory_id2.vars.label }}</label>
  220.                                                                     {{ form_widget(form.classcategory_id2, { 'attr': {'class': 'c-select__native-control mdc-select__native-control' }}) }}
  221.                                                                     <div class="mdc-notched-outline">
  222.                                                                         <div class="mdc-notched-outline__leading"></div>
  223.                                                                         <div class="mdc-notched-outline__notch"></div>
  224.                                                                         <div class="mdc-notched-outline__trailing"></div>
  225.                                                                     </div>
  226.                                                                 </div>
  227.                                                                 {{ form_errors(form.classcategory_id2, {'label_attr': {'class': 'mdc-select-helper-text mdc-select-helper-text--validation-msg'}}) }}
  228.                                                             </div>
  229.                                                         </div>
  230.                                                     {% endif %}
  231.                                                 {% endif %}
  232.                                                 <div class="c-list-product__form-box">
  233.                                                     <div class="c-list-product__form-box-item">
  234.                                                         <div class="c-text-field mdc-text-field mdc-text-field--outlined">
  235.                                                             {{ form_widget(form.quantity, {'attr': {'class': 'c-text-field__input mdc-text-field__input quantity' }}) }}
  236.                                                             <div class="mdc-notched-outline">
  237.                                                                 <div class="mdc-notched-outline__leading"></div>
  238.                                                                 <div class="mdc-notched-outline__notch">
  239.                                                                     <label class="c-floating-label mdc-floating-label" for="quantity{{ Product.id }}">数量</label>
  240.                                                                 </div>
  241.                                                                 <div class="mdc-notched-outline__trailing"></div>
  242.                                                             </div>
  243.                                                         </div>
  244.                                                         {{ form_errors(form.quantity) }}
  245.                                                     </div>
  246.                                                 </div>
  247.                                                 {{ form_rest(form) }}
  248.                                             </div>
  249.                                         </form>
  250.                                         <div class="c-list-product__actions">
  251.                                             <div class="c-list-product__actions-item">
  252.                                                 <button class="c-button is-secondary c-button--unelevated mdc-button mdc-button--unelevated add-cart" type="submit" data-cartid="{{ Product.id }}" form="productForm{{ Product.id }}">
  253.                                                     <span class="c-button__label mdc-button__label">{{ 'カートに入れる'|trans }}</span>
  254.                                                 </button>
  255.                                             </div>
  256.                                         </div>
  257.                                     {% else %}
  258.                                         <div class="c-list-product__actions">
  259.                                             <div class="c-list-product__actions-item">
  260.                                                 <button class="c-button c-button--unelevated mdc-button mdc-button--unelevated" type="button" disabled="disabled">
  261.                                                     <span class="c-button__label mdc-button__label">{{ 'SOLD OUT'|trans }}</span>
  262.                                                 </button>
  263.                                             </div>
  264.                                         </div>
  265.                                     {% endif %}
  266.                                 </section>
  267.                             </li>
  268.                         {% endfor %}
  269.                     </ul>
  270.                     <div class="p-product__modal">
  271.                         <input class="p-product__modal-checkbox" id="p-product__modal-checkbox" type="checkbox">
  272.                         <div class="p-product__modal-overlay">
  273.                             <label class="p-product__modal-overlay-close" for="p-product__modal-checkbox"></label>
  274.                             <div class="p-product__modal-contents">
  275.                                 <label class="p-product__modal-close" for="p-product__modal-checkbox">
  276.                                     <i class="p-product__modal-close-icon material-icons">close</i>
  277.                                 </label>
  278.                                 <div class="p-product__modal-header">
  279.                                     <p class="p-product__modal-message" id="js-product__modal-message">{{ 'カートに追加しました。'|trans }}</p>
  280.                                 </div>
  281.                                 <div class="p-product__modal-actions">
  282.                                     <div class="p-product__modal-actions-item">
  283.                                         <a class="p-product__modal-button c-button c-button--unelevated is-secondary mdc-button mdc-button--unelevated" href="{{ url('cart') }}">
  284.                                             <span class="c-button__label mdc-button__label">{{ 'カートへ進む'|trans }}</span>
  285.                                         </a>
  286.                                     </div>
  287.                                     <div class="p-product__modal-actions-item">
  288.                                         <label class="p-product__modal-button c-button c-button--unelevated is-primary mdc-button mdc-button--unelevated" for="p-product__modal-checkbox">
  289.                                             <span class="c-button__label mdc-button__label">{{ 'お買い物を続ける'|trans }}</span>
  290.                                         </label>
  291.                                     </div>
  292.                                 </div>
  293.                             </div>
  294.                         </div>
  295.                     </div>
  296.                     {% include "pager.twig" with {'pages': pagination.paginationData} %}
  297.                 {% endif %}
  298.             {% endif %}
  299.         </div>
  300.     </section>
  301. {% endblock %}