app/template/bravers/Block/product_sale_block.twig line 1

Open in your IDE?
  1. <div class="topBlocks last-block">
  2.     <div class="titleBlock">
  3.         <div class="titleBlock__name">
  4.             <img class="titleBlock__name__icon" src="{{ asset('assets/img/top/sale.svg') }}" alt="セール商品" width="32" height="27" loading="lazy">
  5.             <h2 class="titleBlock__name__title">セール商品</h2>
  6.         </div>
  7.         <a href="{{ url('product_sale') }}?orderby=2" class="titleBlock__link">もっとみる</a>
  8.     </div>
  9.     <div class="topBlocks__scroll ranking-space">
  10.         {% for Product in SaleProducts %}
  11.             {% set form = sale_forms[Product.id] %}
  12.             <div class="topBlocks__item popular-item">
  13.                 {% set default = 0 %}
  14.                 {% if saleItemInCart[Product.id] is defined %}
  15.                     {% set default = saleItemInCart[Product.id] %}
  16.                 {% endif %}
  17.                 {% set disabled = false %}
  18.                 {% if not Product.isStockDiscontinued %}
  19.                     <input type="hidden" name="stock" class="stock" value="999999999999">
  20.                 {% else %}
  21.                     {% if Product.getStockMin <= default %}
  22.                         {% set disabled = true %}
  23.                     {% endif %}
  24.                     <input type="hidden" name="stock" class="stock" value="{{Product.getStockMin}}">
  25.                 {% endif %}
  26.                 <div class="topBlocks__form">
  27.                     <a href="{{ url('product_detail', {'id': Product.id}) }}"  role="group" >
  28.                         <div class="topBlocks__item__image">
  29.                             <img src="{{ asset(Product.main_list_image|no_image_product, 'save_image') }}" alt=" {{Product.name}}">
  30.                             {% if Product.Tags|length > 0  %}
  31.                                 <ul class="topBlocks__item__image__tags">
  32.                                     {% for Tag in Product.Tags %}
  33.                                         <li class="topBlocks__item__image__tags__tag tag_{{ Tag.id }}">{{ Tag }}</li>
  34.                                     {% endfor %}
  35.                                 </ul>
  36.                             {% endif %}
  37.                         </div>
  38.                         <p class="topBlocks__item__name">
  39.                             {{Product.name}}
  40.                         </p>
  41.                         {% if is_granted('ROLE_USER') %}
  42.                             <div class="topBlocks__item__flex">
  43.                                 <div class="topBlocks__item__price">
  44.                                     {% if Product.isInSale %}
  45.                                         <p class="topBlocks__item__price__sale">セール商品</p>
  46.                                     {% endif %}
  47.                                     {% if Product.hasProductClass %}
  48.                                         {% if Product.getPrice02Min == Product.getPrice02Max %}
  49.                                             {{ Product.getPrice02IncTaxMin|price }}(税込)
  50.                                         {% else %}
  51.                                             {{ Product.getPrice02IncTaxMin|price }} ~ <span>{{ Product.getPrice02IncTaxMax|price }}(税込)</span>
  52.                                         {% endif %}
  53.                                     {% else %}
  54.                                         {{ Product.getPrice02IncTaxMin|price }}(税込)
  55.                                     {% endif %}
  56.                                 </div>
  57.                                 <div class="ec-shelfGrid__item-flex__favorite">
  58.                                     <form class="ec-favoriteForm" action="?" method="?">
  59.                                         <div class="ec-productRole__btn">
  60.                                             <button data-method="POST" data-action="{{ url('product_add_favorite', {id:Product.id}) }}" id="favorite" class="{% if isSaleFavorite[Product.id] is defined and isSaleFavorite[Product.id] == true %} d-none {% endif %}topBlocks__item__favorite ec-blockFavoriteBtn ec-blockBtn--cancel ec-shelfGrid__item-flex__favorite__btn">
  61.                                                 <img src="{{ asset('assets/img/favorite/before.svg') }}" alt="お気に入り" width="24" height="24" loading="lazy">
  62.                                             </button>
  63.                                             <button data-method="DELETE" data-action="{{ url('product_favorite_delete', {id:Product.id}) }}" id="favorite" class="{% if isSaleFavorite[Product.id] is defined and isSaleFavorite[Product.id] == false %} d-none {% endif %} topBlocks__item__favorite ec-blockFavoriteBtnDisable ec-blockBtn--cancel ec-shelfGrid__item-flex__favorite__btn">
  64.                                                 <img src="{{ asset('assets/img/favorite/after.svg') }}" alt="お気に入り" width="24" height="24" loading="lazy">
  65.                                             </button>
  66.                                         </div>
  67.                                     </form>
  68.                                 </div>
  69.                             </div>
  70.                         {% endif %}
  71.                     </a>
  72.                     {% if is_granted('ROLE_USER') %}
  73.                         <form class="topBlocks__form" name="form{{ Product.id }}" id="popularProductForm{{ Product.id }}" action="{{ url('product_add_cart', {id:Product.id}) }}" method="post">
  74.                         {% if not Product.getStockUnlimitedMin and Product.getStockMin <= 0 and Product.isStockDiscontinued %}
  75.                             <div class="ec-productRole__btn">
  76.                                 <button type="button" class="ec-disabled__btn" disabled="disabled">
  77.                                     {{ '在庫なし'|trans }}
  78.                                 </button>
  79.                             </div>
  80.                         {% else %}
  81.                             <div class="ec-numberInput d-none"><span>{{ '数量'|trans }}</span>
  82.                                 {{ form_widget(form.quantity, {'attr': {'class': 'quantity'}} ) }}
  83.                                 {{ form_errors(form.quantity) }}
  84.                             </div>
  85.                             <div class="d-none">
  86.                                 {{ form_rest(form) }}
  87.                             </div>
  88.                             <div class="ec-productRole__btn--group ec-productRole__btn {% if saleItemInCart[Product.id] is defined %} d-block {% else %} d-none {% endif %}">
  89.                                 <div class="d-flex align-items-center ec-productRole__btn-wrapper">
  90.                                     <button class="minus__btn" data-cartid="{{ Product.id }}" form="productForm{{ Product.id }}">
  91.                                         <span>−</span>
  92.                                     </button>
  93.                                     <span class="quantity_label quantity_label_{{ Product.id }}">{{ default }}</span>
  94.                                     <button class="plus__btn" data-cartid="{{ Product.id }}" form="productForm{{ Product.id }}" {% if disabled %}disabled{% endif %}>
  95.                                         <span>+</span>
  96.                                     </button>
  97.                                 </div>
  98.                             </div>
  99.                             <div class="ec-productRole__btn--only ec-productRole__btn {% if saleItemInCart[Product.id] is defined %} d-none {% else %} d-block {% endif %}">
  100.                                 <button type="submit" class="ec-regular__btn add-popular-cart" data-cartid="{{ Product.id }}" form="productForm{{ Product.id }}">
  101.                                     {{ 'カートに入れる'|trans }}
  102.                                 </button>
  103.                             </div>
  104.                         {% endif %}
  105.                         </form>
  106.                     {% endif %}
  107.                 </div>
  108.             </div>
  109.         {% endfor %}
  110.         <div class="ec-modal ec-popular-modal">
  111.             <div class="ec-modal-overlay">
  112.                 <div class="ec-modal-wrap">
  113.                     <span class="ec-modal-close"><span class="ec-icon"><img src="{{ asset('assets/icon/cross-dark.svg') }}" alt=""/></span></span>
  114.                     <div id="ec-modal-header" class="text-center">{{ 'カートに追加しました。'|trans }}</div>
  115.                     <div class="ec-modal-box">
  116.                         <div class="ec-role">
  117.                             <span class="ec-inlineBtn--cancel">{{ 'お買い物を続ける'|trans }}</span>
  118.                             <a href="{{ url('cart') }}" class="ec-inlineBtn--action">{{ 'カートへ進む'|trans }}</a>
  119.                         </div>
  120.                     </div>
  121.                 </div>
  122.             </div>
  123.         </div>
  124.     </div>
  125. </div>
  126. <script>
  127.     $('.ec-modal-wrap').on('click', function(e) {
  128.         // モーダル内の処理は外側にバブリングさせない
  129.         e.stopPropagation();
  130.     });
  131.     $('.ec-modal-overlay, .ec-modal, .ec-modal-close, .ec-inlineBtn--cancel').on('click', function() {
  132.         $('.ec-modal').hide()
  133.     });
  134.     var modalTimer;
  135.     $('.add-popular-cart').on('click', function(e) {
  136.         var self = $(this);
  137.         onAddCart(e, $(this), 1, function() {
  138.             checkRenderButton();
  139.             window.clearTimeout(modalTimer);
  140.             $('.ec-modal.ec-history-modal').show()
  141.             modalTimer = window.setTimeout(function() {
  142.                 $('.ec-modal').hide();
  143.             }, 1500)
  144.         });
  145.     });
  146.     $(document).on('click', '.minus__btn', function(e) {
  147.         e.preventDefault();
  148.         e.stopPropagation();
  149.         onAddCart(e, $(this), -1);
  150.     })
  151.     $('.plus__btn').on('click', function(e) {
  152.         e.preventDefault();
  153.         e.stopPropagation();
  154.         onAddCart(e, $(this), 1);
  155.     });
  156. </script>