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