app/template/bravers/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.             var modalTimer;
  33.             $('.add-cart').on('click', function(e) {
  34.                 var self = $(this);
  35.                 onAddCart(e, $(this), 1, function() {
  36.                     var $form = self.parents('li');
  37.                     $form.find(".ec-productRole__btn--only").addClass("d-none");
  38.                     $form.find(".ec-productRole__btn--group").removeClass("d-none");
  39.                     window.clearTimeout(modalTimer);
  40.                     $('.ec-modal').show()
  41.                     modalTimer = window.setTimeout(function() {
  42.                         $('.ec-modal').hide();
  43.                     }, 1500)
  44.                 });
  45.             });
  46.             $('.minus__btn').on('click', function(e) {
  47.                 onAddCart(e, $(this), -1);
  48.             })
  49.             $('.plus__btn').on('click', function(e) {
  50.                 onAddCart(e, $(this));
  51.             })
  52.             function onAddCart(e, self, quantity = 1, callback) {
  53.                 var $form = $(self).parents('li').find('form.productForm');
  54.                 // 個数フォームのチェック
  55.                 $form.parent().find('.quantity').val(quantity);
  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.                         $(self).prop('disabled', true);
  65.                     }
  66.                 }).done(function(data) {
  67.                     // レスポンス内のメッセージをalertで表示
  68.                     $.each(data.messages, function() {
  69.                         $('#ec-modal-header').text(this);
  70.                     });
  71.                     var $quantityLabelEl = $(self).parents('li').find('.quantity_label');
  72.                     $quantityLabelEl.text($quantityLabelEl.text() * 1 + quantity * 1);
  73.                     if(callback) {
  74.                         callback();
  75.                     }
  76.                     // カートブロックを更新する
  77.                     $.ajax({
  78.                         url: '{{ url('block_cart') }}',
  79.                         type: 'GET',
  80.                         dataType: 'html'
  81.                     }).done(function(html) {
  82.                         $('.ec-headerRole__cart').html(html);
  83.                     });
  84.                 }).fail(function(data) {
  85.                     alert('{{ 'カートへの追加に失敗しました。'|trans }}');
  86.                     $(self).prop('disabled', false);
  87.                 }).always(function(data) {
  88.                     var $parent = $(self).parents('li');
  89.                     let stockVal = $parent.find('.stock').val() * 1;
  90.                     var $quantityLabelEl = $parent.find('.quantity_label');
  91.                     var _quantity = $quantityLabelEl.text() * 1;
  92.                     if(_quantity == 0) {
  93.                         // enable minus button
  94.                         $(self).prop('disabled', false);
  95.                         $parent.find(".ec-productRole__btn--only").removeClass("d-none");
  96.                         $parent.find(".ec-productRole__btn--group").addClass("d-none");
  97.                     }
  98.                     if(_quantity > 0 && _quantity < stockVal) {
  99.                         // Buttonを有効にする
  100.                         $(self).prop('disabled', false);
  101.                         $parent.find('.plus__btn').prop('disabled', false);
  102.                     }
  103.                 });
  104.             }
  105.         });
  106.         $('.ec-modal-wrap').on('click', function(e) {
  107.             // モーダル内の処理は外側にバブリングさせない
  108.             e.stopPropagation();
  109.         });
  110.         $('.ec-modal-overlay, .ec-modal, .ec-modal-close, .ec-inlineBtn--cancel').on('click', function() {
  111.             $('.ec-modal').hide()
  112.         });
  113.     </script>
  114. {% endblock %}
  115. {% block main %}
  116.     <div class="ec-searchnavRole__topicpath">
  117.         <ul class="breadcrumb w-p">
  118.             <li class="breadcrumb__item">
  119.                 <a href="{{ url('product_list') }}" class="breadcrumb__item__link">
  120.                     ホーム
  121.                 </a>
  122.             </li>
  123.             <li class="breadcrumb__item">
  124.                 <p class="breadcrumb__item__arrow">></p>
  125.             </li>
  126.             <li class="breadcrumb__item">
  127.                 <a href="{{ url('product_list') }}" class="breadcrumb__item__link">
  128.                     商品一覧
  129.                 </a>
  130.             </li>
  131.             {% if Category is not null %}
  132.                 <li class="breadcrumb__item">
  133.                     <p class="breadcrumb__item__arrow">></p>
  134.                 </li>
  135.                 {% for Path in Category.path %}
  136.                     {% if Path.id != constant('Customize\\Common\\Constant::MANUFACTURER_CATEGORY_ID')
  137.                         and Path.id != constant('Customize\\Common\\Constant::DEFAULT_CATEGORY_ID') %}
  138.                         <li class="breadcrumb__item">
  139.                             <a class="breadcrumb__item__link" href="{{ url('product_list') }}?category_id={{ Path.id }}">{{ Path.name }}</a>
  140.                         </li>
  141.                         {%- if loop.last == false %}
  142.                             <li class="breadcrumb__item">
  143.                                 <p class="breadcrumb__item__arrow">></p>
  144.                             </li>
  145.                         {% endif -%}
  146.                     {% endif %}
  147.                 {% endfor %}
  148.             {% endif %}
  149.             {# {% if search_form.vars.value and search_form.vars.value.name %}
  150.                 <li class="ec-topicpath__divider">|</li>
  151.                 <li class="ec-topicpath__item">{{ '「%name%」の検索結果'|trans({ '%name%': search_form.vars.value.name }) }}</li>
  152.             {% endif %} #}
  153.         </ul>
  154.     </div>
  155.     <div class="ec-pageHeader contentHeader">
  156.         <h1>{{ '商品一覧'|trans }}</h1>
  157.     </div>
  158.     {% if search_form.category_id.vars.errors|length > 0 %}
  159.         <div class="ec-searchnavRole">
  160.             <p class="errormsg text-danger">{{ 'ご指定のカテゴリは存在しません'|trans }}</p>
  161.         </div>
  162.     {% else %}
  163.         <div class="ec-searchnavRole">
  164.             <form name="form1" id="form1" method="get" action="?">
  165.                 {% for item in search_form %}
  166.                     <input type="hidden" id="{{ item.vars.id }}"
  167.                            name="{{ item.vars.full_name }}"
  168.                            {% if item.vars.value is not empty %}value="{{ item.vars.value }}" {% endif %}/>
  169.                 {% endfor %}
  170.             </form>
  171.             <div class="ec-searchnavRole__infos">
  172.                 <div class="ec-searchnavRole__counter">
  173.                     {% if pagination.totalItemCount > 0 %}
  174.                         <p class="ec-searchnavRole__counter__title">検索結果</p>
  175.                         {{ '<p class="ec-searchnavRole__counter__number">%count%件</p>'|trans({ '%count%': pagination.totalItemCount })|raw }}
  176.                     {% else %}
  177.                         <span>{{ 'お探しの商品は見つかりませんでした'|trans }}</span>
  178.                     {% endif %}
  179.                 </div>
  180.                 {% if pagination.totalItemCount > 0 %}
  181.                     <div class="ec-searchnavRole__actions">
  182.                         <div class="ec-select">
  183.                             {{ form_widget(search_form.disp_number, {'id': '', 'attr': {'class': 'disp-number'}}) }}
  184.                             {{ form_widget(search_form.orderby, {'id': '', 'attr': {'class': 'order-by'}}) }}
  185.                         </div>
  186.                     </div>
  187.                 {% endif %}
  188.             </div>
  189.         </div>
  190.         <ul class="stockList">
  191.             <li class="stockList__block">
  192.                 <p class="stockList__block__text">在庫あり:</p>
  193.                 <p class="stockList__block__mark">◎</p>
  194.             </li>
  195.             <li class="stockList__block">
  196.                 <p class="stockList__block__text">残りわずか:</p>
  197.                 <p class="stockList__block__mark">○</p>
  198.             </li>
  199.             <li class="stockList__block">
  200.                 <p class="stockList__block__text">取り寄せ:</p>
  201.                 <p class="stockList__block__mark">■</p>
  202.             </li>
  203.         </ul>
  204.         {% if pagination.totalItemCount > 0 %}
  205.             {% if isShowProductImage %}
  206.             <div class="ec-shelfRole">
  207.                 <ul class="ec-shelfGrid">
  208.                     {% for Product in pagination %}
  209.                         <li class="ec-shelfGrid__item">
  210.                             <a href="{{ url('product_detail', {'id': Product.id}) }}">
  211.                                 <div class="ec-shelfGrid__item-image">
  212.                                     <img src="{{ asset(Product.main_list_image|no_image_product, 'save_image') | imagine_filter('resize', {
  213.     "thumbnail": {"size": [250, 250] }}) }}" alt="{{ Product.name }}" {% if loop.index > 5 %} loading="lazy"{% endif %}>
  214.                                     {% if Product.Tags|length > 0  %}
  215.                                     <ul class="ec-shelfGrid__item-tags">
  216.                                         {% for Tag in Product.Tags %}
  217.                                             <li class="ec-shelfGrid__item-tags__tag tag_{{ Tag.id }}">{{ Tag }}</li>
  218.                                         {% endfor %}
  219.                                     </ul>
  220.                                     {% endif %}
  221.                                 </div>
  222.                                 <p class="ec-shelfGrid__item-name">{{ Product.name }}</p>
  223.                                 {% if is_granted('ROLE_USER') %}
  224.                                 <div class="ec-shelfGrid__item-stock">
  225.                                     <div class="ec-shelfGrid__item-stock__block">
  226.                                         <p class="ec-shelfGrid__item-stock__block__title">
  227.                                             【発送目安】
  228.                                         </p>
  229.                                         <p class="ec-shelfGrid__item-stock__block__detail">
  230.                                             {% if Product.getDeliveryDuration %}
  231.                                                 {{Product.getDeliveryDuration.name}}
  232.                                             {% else %}
  233.                                                 指定なし
  234.                                             {% endif %}
  235.                                         </p>
  236.                                     </div>
  237.                                     <div class="ec-shelfGrid__item-stock__block">
  238.                                         <p class="ec-shelfGrid__item-stock__block__title">
  239.                                             【在庫】
  240.                                         </p>
  241.                                         {# 在庫をマークで表示何個から何個か◎等はこれから確認 #}
  242.                                         <p class="ec-shelfGrid__item-stock__block__detail">
  243.                                             {% if Product.getStockUnlimitedMin or Product.getStockMin >= 10 %}
  244.                                                 ◎
  245.                                             {% else %}
  246.                                                 {% if Product.getStockMin >= 1 and Product.getStockMin <= 9 %}
  247.                                                     ○
  248.                                                 {% endif %}
  249.                                                 {% if Product.getStockMin <= 0 %}
  250.                                                     ■
  251.                                                 {% endif %}
  252.                                             {% endif %}
  253.                                         </p>
  254.                                     </div>
  255.                                 </div>
  256.                                 {# {% if not Product.getStockUnlimitedMin %}
  257.                                     <p>
  258.                                         発送可能{{Product.getStockMin}}個
  259.                                     </p>
  260.                                 {% endif %} #}
  261.                                 {% if Product.description_list %}
  262.                                     <p>{{ Product.description_list|raw|nl2br }}</p>
  263.                                 {% endif %}
  264.                                 <div class="ec-shelfGrid__item-flex">
  265.                                     <p class="price02-default ec-shelfGrid__item-price">
  266.                                         {% if Product.isInSale %}
  267.                                             <span class="ec-shelfGrid__item-price__sale">セール商品</span>
  268.                                         {% endif %}
  269.                                         {% if Product.hasProductClass %}
  270.                                             {% if Product.getPrice02Min == Product.getPrice02Max %}
  271.                                                 {{ Product.getPrice02IncTaxMin|price }}
  272.                                             {% else %}
  273.                                                 {{ Product.getPrice02IncTaxMin|price }} ~ {{ Product.getPrice02IncTaxMax|price }}
  274.                                             {% endif %}
  275.                                         {% else %}
  276.                                             {{ Product.getPrice02IncTaxMin|price }}
  277.                                         {% endif %}
  278.                                     </p>
  279.                                     <div class="ec-shelfGrid__item-flex__favorite">
  280.                                         <form class="ec-favoriteForm" action="?" method="?">
  281.                                             <div class="ec-productRole__btn">
  282.                                                 <button data-method="POST" data-action="{{ url('product_add_favorite', {id:Product.id}) }}" id="favorite" class="{% if isFavorite[Product.id] is defined and isFavorite[Product.id] == true %} d-none {% endif %} ec-blockFavoriteBtn ec-blockBtn--cancel ec-shelfGrid__item-flex__favorite__btn">
  283.                                                     <img src="{{ asset('assets/img/favorite/before.svg') }}" alt="お気に入り" width="24" height="24" loading="lazy">
  284.                                                 </button>
  285.                                                 <button data-method="DELETE" data-action="{{ url('product_favorite_delete', {id:Product.id}) }}" id="favorite" class="{% if isFavorite[Product.id] is defined and isFavorite[Product.id] == false %} d-none {% endif %}ec-blockFavoriteBtnDisable ec-blockBtn--cancel ec-shelfGrid__item-flex__favorite__btn">
  286.                                                    <img src="{{ asset('assets/img/favorite/after.svg') }}" alt="お気に入り" width="24" height="24" loading="lazy">
  287.                                                 </button>
  288.                                             </div>
  289.                                         </form>
  290.                                     </div>
  291.                                 </div>
  292.                                 {% endif %}
  293.                             </a>
  294.                             {% if is_granted('ROLE_USER') %}
  295.                                 {% if not Product.getStockUnlimitedMin and Product.getStockMin <= 0 and Product.isStockDiscontinued %}
  296.                                     <div class="ec-productRole__btn">
  297.                                         <button type="button" class="ec-disabled__btn" disabled="disabled">
  298.                                             {{ '在庫なし'|trans }}
  299.                                         </button>
  300.                                     </div>
  301.                                 {% else %}
  302.                                     {% set form = forms[Product.id] %}
  303.                                     <form class="productForm" name="form{{ Product.id }}" id="productForm{{ Product.id }}" action="{{ url('product_add_cart', {id:Product.id}) }}" method="post">
  304.                                         <div class="ec-productRole__actions">
  305.                                             {% if form.classcategory_id1 is defined %}
  306.                                                 <div class="ec-select">
  307.                                                     {{ form_widget(form.classcategory_id1) }}
  308.                                                     {{ form_errors(form.classcategory_id1) }}
  309.                                                 </div>
  310.                                                 {% if form.classcategory_id2 is defined %}
  311.                                                     <div class="ec-select">
  312.                                                         {{ form_widget(form.classcategory_id2) }}
  313.                                                         {{ form_errors(form.classcategory_id2) }}
  314.                                                     </div>
  315.                                                 {% endif %}
  316.                                             {% endif %}
  317.                                                 <div class="ec-numberInput d-none"><span>{{ '数量'|trans }}</span>
  318.                                                     {{ form_widget(form.quantity, {'attr': {'class': 'quantity'}} ) }}
  319.                                                     {{ form_errors(form.quantity) }}
  320.                                                 </div>
  321.                                         
  322.                                         </div>
  323.                                         {{ form_rest(form) }}
  324.                                     </form>
  325.                                     {% set default = 0 %}
  326.                                     {% if itemInCart[Product.id] is defined %}
  327.                                         {% set default = itemInCart[Product.id] %}
  328.                                     {% endif %}
  329.                                     {% set disabled = false %}
  330.                                     {% if not Product.isStockDiscontinued %}
  331.                                         <input type="hidden" name="stock" class="stock" value="999999999999">
  332.                                     {% else %}
  333.                                         {% if Product.getStockMin <= default %}
  334.                                             {% set disabled = true %}
  335.                                         {% endif %}
  336.                                         <input type="hidden" name="stock" class="stock" value="{{Product.getStockMin}}">
  337.                                     {% endif %}
  338.                                     <div class="ec-productRole__btn--group ec-productRole__btn {% if itemInCart[Product.id] is defined %} d-block {% else %} d-none {% endif %}">
  339.                                         <div class="d-flex align-items-center ec-productRole__btn-wrapper">
  340.                                             <button class="minus__btn" data-cartid="{{ Product.id }}" form="productForm{{ Product.id }}">
  341.                                                 <span>−</span>
  342.                                             </button>
  343.                                             <span class="quantity_label">{{ default }}</span>
  344.                                             <button class="plus__btn" data-cartid="{{ Product.id }}" form="productForm{{ Product.id }}" {% if disabled %}disabled{% endif %}>
  345.                                                 <span>+</span>
  346.                                             </button>
  347.                                         </div>
  348.                                     </div>
  349.                                     <div class="ec-productRole__btn--only ec-productRole__btn {% if itemInCart[Product.id] is defined %} d-none {% else %} d-block {% endif %}">
  350.                                         <button type="submit" class="ec-regular__btn add-cart" data-cartid="{{ Product.id }}" form="productForm{{ Product.id }}">
  351.                                             {{ 'カートに入れる'|trans }}
  352.                                         </button>
  353.                                     </div>
  354.                                 {% endif %}
  355.                             {% else %}
  356.                                 <a href="{{ url('entry_contact') }}" class="ec-blockProductBtn--action">会員登録はこちら</a>
  357.                             {% endif %}
  358.                         </li>
  359.                     {% endfor %}
  360.                 </ul>
  361.             </div>
  362.             {% else %}
  363.                 <div class="ec-shelfRole">
  364.                     {% include "Block/product_table.twig" with {'pagination': pagination, 'itemInCart': itemInCart, 'forms': forms} %}
  365.                 </div>
  366.             {% endif %}
  367.             <div class="ec-modal">
  368.                 <div class="ec-modal-overlay">
  369.                     <div class="ec-modal-wrap">
  370.                         <div class="ec-modal-box">
  371.                             <div class="ec-role">
  372.                                 <div class="ec-modal-icon">
  373.                                     <img src="{{ asset('assets/img/icon/icon_cart.png', 'user_data') }}" alt="">
  374.                                 </div>
  375.                             </div>
  376.                         </div>
  377.                         <div id="ec-modal-header" class="text-center">{{ 'カートに追加しました。'|trans }}</div>
  378.                     </div>
  379.                 </div>
  380.             </div>
  381.             <ul class="stockList bottom">
  382.                 <li class="stockList__block">
  383.                     <p class="stockList__block__text">在庫あり:</p>
  384.                     <p class="stockList__block__mark">◎</p>
  385.                 </li>
  386.                 <li class="stockList__block">
  387.                     <p class="stockList__block__text">残りわずか:</p>
  388.                     <p class="stockList__block__mark">○</p>
  389.                 </li>
  390.                 <li class="stockList__block">
  391.                     <p class="stockList__block__text">取り寄せ:</p>
  392.                     <p class="stockList__block__mark">■</p>
  393.                 </li>
  394.             </ul>
  395.             <div class="ec-pagerRole">
  396.                 {% include "pager.twig" with {'pages': pagination.paginationData} %}
  397.             </div>
  398.         {% endif %}
  399.     {% endif %}
  400. {% endblock %}