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