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

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