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

Open in your IDE?
  1. {% if is_granted('ROLE_USER') %}
  2.     <div class="topBlocks">
  3.         <div class="titleBlock">
  4.             <div class="titleBlock__name">
  5.                 <img class="titleBlock__name__icon" src="{{ asset('assets/img/top/history.svg') }}" alt="購入履歴" width="32" height="32" loading="lazy">
  6.                 <h2 class="titleBlock__name__title">購入履歴</h2>
  7.             </div>
  8.             <a href="{{ url('history_product_list') }}" class="titleBlock__link">もっとみる</a>
  9.         </div>
  10.         <div class="topBlocks__scroll">
  11.             {% for Product in Products %}
  12.                 <div class="topBlocks__item popular-item">
  13.                     {% set form = history_forms[Product.id] %}
  14.                     {% set default = 0 %}
  15.                     {% if historyItemInCart[Product.id] is defined %}
  16.                         {% set default = historyItemInCart[Product.id] %}
  17.                     {% endif %}
  18.                     {% set disabled = false %}
  19.                     {% if not Product.isStockDiscontinued %}
  20.                         <input type="hidden" name="stock" class="stock" value="999999999999">
  21.                     {% else %}
  22.                         {% if Product.getStockMin <= default %}
  23.                             {% set disabled = true %}
  24.                         {% endif %}
  25.                         <input type="hidden" name="stock" class="stock" value="{{Product.getStockMin}}">
  26.                     {% endif %}
  27.                     <div class="topBlocks__form">
  28.                         <a href="{{ url('product_detail', {'id': Product.id}) }}"  role="group" >
  29.                             <div class="topBlocks__item__image">
  30.                                 <img src="{{ asset(Product.main_list_image|no_image_product, 'save_image') }}" alt="{{Product.name}}">
  31.                                 {% if Product.Tags|length > 0  %}
  32.                                     <ul class="topBlocks__item__image__tags">
  33.                                         {% for Tag in Product.Tags %}
  34.                                             <li class="topBlocks__item__image__tags__tag tag_{{ Tag.id }}">{{ Tag }}</li>
  35.                                         {% endfor %}
  36.                                     </ul>
  37.                                 {% endif %}
  38.                             </div>
  39.                             <p class="topBlocks__item__name">
  40.                                 {{Product.name}}
  41.                             </p>
  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 isHistoryFavorite[Product.id] is defined and isHistoryFavorite[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 isHistoryFavorite[Product.id] is defined and isHistoryFavorite[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.                         </a>
  71.                         <form class="topBlocks__form" name="form{{ Product.id }}" id="historyProductForm{{ Product.id }}" action="{{ url('product_add_cart', {id:Product.id}) }}" method="post">
  72.                         {% if not Product.getStockUnlimitedMin and Product.getStockMin <= 0 and Product.isStockDiscontinued %}
  73.                             <div class="ec-productRole__btn">
  74.                                 <button type="button" class="ec-disabled__btn" disabled="disabled">
  75.                                     {{ '在庫なし'|trans }}
  76.                                 </button>
  77.                             </div>
  78.                         {% else %}
  79.                             <div class="ec-numberInput d-none"><span>{{ '数量'|trans }}</span>
  80.                                 {{ form_widget(form.quantity, {'attr': {'class': 'quantity'}} ) }}
  81.                                 {{ form_errors(form.quantity) }}
  82.                             </div>
  83.                             <div class="d-none">
  84.                                 {{ form_rest(form) }}
  85.                             </div>
  86.                             <div class="ec-productRole__btn--group ec-productRole__btn {% if historyItemInCart[Product.id] is defined %} d-block {% else %} d-none {% endif %}">
  87.                                 <div class="d-flex align-items-center ec-productRole__btn-wrapper">
  88.                                     <button class="minus__btn" data-cartid="{{ Product.id }}" form="productForm{{ Product.id }}">
  89.                                         <span>−</span>
  90.                                     </button>
  91.                                     <span class="quantity_label quantity_label_{{ Product.id }}">{{ default }}</span>
  92.                                     <button class="plus__btn" data-cartid="{{ Product.id }}" form="productForm{{ Product.id }}" {% if disabled %}disabled{% endif %}>
  93.                                         <span>+</span>
  94.                                     </button>
  95.                                 </div>
  96.                             </div>
  97.                             <div class="ec-productRole__btn--only ec-productRole__btn {% if historyItemInCart[Product.id] is defined %} d-none {% else %} d-block {% endif %}">
  98.                                 <button type="submit" class="ec-regular__btn add-history-cart" data-cartid="{{ Product.id }}" form="productForm{{ Product.id }}">
  99.                                     {{ 'カートに入れる'|trans }}
  100.                                 </button>
  101.                             </div>
  102.                         {% endif %}
  103.                         </form>
  104.                     </div>
  105.                 </div>
  106.             {% endfor %}
  107.             <div class="ec-modal ec-history-modal">
  108.                 <div class="ec-modal-overlay">
  109.                     <div class="ec-modal-wrap">
  110.                         <div class="ec-modal-box">
  111.                             <div class="ec-role">
  112.                                 <div class="ec-modal-icon">
  113.                                     <img src="{{ asset('assets/img/icon/icon_cart.png', 'user_data') }}" alt="">
  114.                                 </div>
  115.                             </div>
  116.                         </div>
  117.                         <div id="ec-modal-header" class="text-center">{{ 'カートに追加しました。'|trans }}</div>
  118.                     </div>
  119.                 </div>
  120.             </div>
  121.         </div>
  122.     </div>
  123. {% endif %}
  124. <script>
  125.     $('.ec-modal-wrap').on('click', function(e) {
  126.         // モーダル内の処理は外側にバブリングさせない
  127.         e.stopPropagation();
  128.     });
  129.     $('.ec-modal-overlay, .ec-modal, .ec-modal-close, .ec-inlineBtn--cancel').on('click', function() {
  130.         $('.ec-modal').hide()
  131.     });
  132.     var modalTimer;
  133.     $('.add-history-cart').on('click', function(e) {
  134.         var self = $(this);
  135.         onAddCart(e, $(this), 1, function() {
  136.             checkRenderButton();
  137.             window.clearTimeout(modalTimer);
  138.             $('.ec-modal.ec-history-modal').show()
  139.             modalTimer = window.setTimeout(function() {
  140.                 $('.ec-modal').hide();
  141.             }, 1500)
  142.         });
  143.     });
  144.     $(document).on('click', '.minus__btn', function(e) {
  145.         e.preventDefault();
  146.         e.stopPropagation();
  147.         onAddCart(e, $(this), -1);
  148.     })
  149.     $('.plus__btn').on('click', function(e) {
  150.         e.preventDefault();
  151.         e.stopPropagation();
  152.         onAddCart(e, $(this), 1);
  153.     });
  154. </script>
  155.