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

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