app/template/default/Block/cart.twig line 1

Open in your IDE?
  1. {#
  2. This file is part of EC-CUBE
  3. Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
  4. http://www.ec-cube.co.jp/
  5. For the full copyright and license information, please view the LICENSE
  6. file that was distributed with this source code.
  7. #}
  8. {% block javascript %}
  9. <script>
  10.     $(document).ready(function () {
  11.         var isCartPage = $('body').find('#isCartPage').length;
  12.         $('.ec-cartNaviIsset .ec-cartNaviIsset__cart').each(function () {
  13.             var btnRemove = $(this).find('.removeProduct');
  14.             $(btnRemove).click(function (e) { 
  15.                 e.preventDefault();
  16.                 var $link = $(this);
  17.                 var url = $link.data('url');
  18.                 var message = $link.data('message');
  19.                 if (!confirm(message)) {
  20.                     return;
  21.                 }
  22.                 $.ajax({    
  23.                     url: url,
  24.                     type: 'POST',
  25.                     data: {
  26.                         _method: 'PUT',
  27.                     },
  28.                     headers: {
  29.                         'X-CSRF-Token':  $(this).data('csrf-token'),
  30.                         'X-Requested-With': 'XMLHttpRequest',
  31.                     },
  32.                     success: function (response) {
  33.                         alert('商品を削除しました。');
  34.                         if (isCartPage) {
  35.                             location.reload();
  36.                         } else {
  37.                             $link.closest('.ec-cartNaviIsset__cart').remove();
  38.                             var newText = countProductCart();
  39.                             if ( newText == 0) {
  40.                                 $('.ec-cartNavi__badge').text(newText);
  41.                                 $('.ec-cartNaviIsset').remove();
  42.                                 $('.ec-cartNaviWrap').append('<div class="ec-cartNaviNull is-active" bis_skin_checked="1"><div class="ec-cartNaviNull__message" bis_skin_checked="1"><p>現在カート内に商品はございません。</p></div></div>');
  43.                             } else {
  44.                                 $('.ec-cartNavi__badge').text(newText);
  45.                             }
  46.                         }
  47.                     },
  48.                     error: function (xhr, status, error) {
  49.                         console.error('Error:', error);
  50.                         alert('エラーが発生しました。もう一度お試しください。');
  51.                     }
  52.                 });
  53.             });
  54.         });
  55.     });
  56.     function countProductCart() {
  57.         return $('.ec-cartNaviIsset .ec-cartNaviIsset__cart').length;
  58.     }
  59. </script>
  60. {% endblock javascript %}
  61. {% set Carts = get_all_carts() %}
  62. {% set totalPrice = get_carts_total_price() %}
  63. {% set totalQuantity = get_carts_total_quantity() %}
  64. <div class="ec-cartNaviWrap">
  65.     <div class="text-line sp">
  66.         <p>LINEにお友達追加で<br />
  67.             今ならお得なクーポン発行中!!
  68.             </p>
  69.     </div>
  70.     <div class="item-nav link-line">
  71.         <a href="https://lin.ee/5FbNJH7s" target="_blank"><img src="{{ asset('assets/img/common/logo-line.png') }}" alt="友だち追加"></a>
  72.         <div class="group">
  73.             <p>LINEにお友達追加で、<br />
  74.                 今ならお得なクーポン発行中!!
  75.                 </p>
  76.             <a href="https://lin.ee/5FbNJH7s" target="_blank" class="btn-link-line">こちらをクリック</a>
  77.         </div>
  78.     </div>
  79.     <div class="item-nav">
  80.         <a href="{{ url('contact') }}"><img src="{{ asset('assets/img/common/ic-mess.png') }}" alt=""></a>
  81.     </div>
  82.     {% if is_granted('ROLE_USER') %}        
  83.         <div class="item-nav">
  84.             <a href="{{ url('mypage') }}"><img src="{{ asset('assets/img/common/ic-user.png') }}" alt=""></a>
  85.         </div>
  86.         {# {% if BaseInfo.option_favorite_product %}
  87.             <div class="item-nav">
  88.                 <a href="{{ url('mypage_favorite') }}" style="display: flex;">
  89.                     <i class="ec-headerNav__itemIcon far fa-heart fa-fw" style="color: #fff;font-size: 2rem;"></i>
  90.                 </a>               
  91.             </div>
  92.         {% endif %} #}
  93.     {% else %}
  94.         <div class="item-nav">
  95.             <a href="{{ url('mypage_login') }}"><img src="{{ asset('assets/img/common/ic-user.png') }}" alt=""></a>
  96.         </div>        
  97.     {% endif %}
  98.     {% set Carts = get_all_carts() %}
  99.     {% set totalPrice = get_carts_total_price() %}
  100.     {% set totalQuantity = get_carts_total_quantity() %}
  101.     <div class="ec-cartNavi">
  102.         <a href="javascript:void(0);"><img src="{{ asset('assets/img/common/ic-cart.png') }}" alt=""></a> 
  103.         <span class="ec-cartNavi__badge">{{ totalQuantity|number_format }}</span>
  104.     </div>
  105.     {% if totalQuantity > 0 %}
  106.         <div class="ec-cartNaviIsset">
  107.             {% for Cart in Carts %}
  108.                 {% for CartItem in Cart.CartItems %}
  109.                     {% set ProductClass = CartItem.ProductClass %}
  110.                     {% set Product = ProductClass.Product %}
  111.                     <div class="ec-cartNaviIsset__cart">
  112.                         <div class="ec-cartNaviIsset__cartDelete">
  113.                             <a data-url="{{ url('cart_handle_remove_item', {'operation': 'remove', 'productClassId': ProductClass.id }) }}" class="ec-icon removeProduct" data-method="put" data-message="カートから商品を削除してもよろしいですか?" data-csrf-token="{{ csrf_token('cart_handle_item') }}" >
  114.                                 <img src="{{ asset('assets/icon/cross.svg') }}" alt="delete">
  115.                             </a>
  116.                         </div>
  117.                         <div class="ec-cartNaviIsset__cartImage">
  118.                             <img src="{{ asset(Product.MainListImage|no_image_product, 'save_image') }}" alt="{{ Product.name }}">
  119.                         </div>
  120.                         <div class="ec-cartNaviIsset__cartContent">
  121.                             <div class="ec-cartNaviIsset__cartContentTitle">{{ Product.name }}
  122.                                 <div class="ec-font-size-1">
  123.                                     {% if ProductClass.ClassCategory1 and ProductClass.ClassCategory1.id %}
  124.                                         {{ ProductClass.ClassCategory1.ClassName.name }}:{{ ProductClass.ClassCategory1 }}
  125.                                     {% endif %}
  126.                                     {% if ProductClass.ClassCategory2 and ProductClass.ClassCategory2.id %}
  127.                                         <br>{{ ProductClass.ClassCategory2.ClassName.name }}:{{ ProductClass.ClassCategory2 }}
  128.                                     {% endif %}
  129.                                 </div>
  130.                             </div>
  131.                             <div class="ec-cartNaviIsset__cartContentPrice">
  132.                                 {{ CartItem.price|price }}
  133.                                 <div class="ec-cartNaviIsset__cartContentTax">{{ '税込'|trans }}</div>
  134.                             </div>
  135.                             <div class="ec-cartNaviIsset__cartContentNumber">{{ '数量'|trans }} {{ CartItem.quantity|number_format }}</div>
  136.                         </div>
  137.                     </div>
  138.                 {% endfor %}
  139.             {% endfor %}
  140.             <div class="ec-cartNaviIsset__action">
  141.                 <a class="ec-blockBtn--action" href="{{ url('cart') }}">{{ 'カートへ進む'|trans }}</a>
  142.                 <a class="ec-blockBtn ec-cartNavi--cancel">{{ 'キャンセル'|trans }}</a>
  143.             </div>
  144.         </div>
  145.     {% else %}
  146.         <div class="ec-cartNaviNull">
  147.             <div class="ec-cartNaviNull__message">
  148.                 <p>{{ '現在カート内に商品はございません。'|trans }}</p>
  149.             </div>
  150.         </div>
  151.     {% endif %}
  152. </div>