{#
This file is part of EC-CUBE
Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
http://www.ec-cube.co.jp/
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% block javascript %}
<script>
$(document).ready(function () {
var isCartPage = $('body').find('#isCartPage').length;
$('.ec-cartNaviIsset .ec-cartNaviIsset__cart').each(function () {
var btnRemove = $(this).find('.removeProduct');
$(btnRemove).click(function (e) {
e.preventDefault();
var $link = $(this);
var url = $link.data('url');
var message = $link.data('message');
if (!confirm(message)) {
return;
}
$.ajax({
url: url,
type: 'POST',
data: {
_method: 'PUT',
},
headers: {
'X-CSRF-Token': $(this).data('csrf-token'),
'X-Requested-With': 'XMLHttpRequest',
},
success: function (response) {
alert('商品を削除しました。');
if (isCartPage) {
location.reload();
} else {
$link.closest('.ec-cartNaviIsset__cart').remove();
var newText = countProductCart();
if ( newText == 0) {
$('.ec-cartNavi__badge').text(newText);
$('.ec-cartNaviIsset').remove();
$('.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>');
} else {
$('.ec-cartNavi__badge').text(newText);
}
}
},
error: function (xhr, status, error) {
console.error('Error:', error);
alert('エラーが発生しました。もう一度お試しください。');
}
});
});
});
});
function countProductCart() {
return $('.ec-cartNaviIsset .ec-cartNaviIsset__cart').length;
}
</script>
{% endblock javascript %}
{% set Carts = get_all_carts() %}
{% set totalPrice = get_carts_total_price() %}
{% set totalQuantity = get_carts_total_quantity() %}
<div class="ec-cartNaviWrap">
<div class="text-line sp">
<p>LINEにお友達追加で<br />
今ならお得なクーポン発行中!!
</p>
</div>
<div class="item-nav link-line">
<a href="https://lin.ee/5FbNJH7s" target="_blank"><img src="{{ asset('assets/img/common/logo-line.png') }}" alt="友だち追加"></a>
<div class="group">
<p>LINEにお友達追加で、<br />
今ならお得なクーポン発行中!!
</p>
<a href="https://lin.ee/5FbNJH7s" target="_blank" class="btn-link-line">こちらをクリック</a>
</div>
</div>
<div class="item-nav">
<a href="{{ url('contact') }}"><img src="{{ asset('assets/img/common/ic-mess.png') }}" alt=""></a>
</div>
{% if is_granted('ROLE_USER') %}
<div class="item-nav">
<a href="{{ url('mypage') }}"><img src="{{ asset('assets/img/common/ic-user.png') }}" alt=""></a>
</div>
{# {% if BaseInfo.option_favorite_product %}
<div class="item-nav">
<a href="{{ url('mypage_favorite') }}" style="display: flex;">
<i class="ec-headerNav__itemIcon far fa-heart fa-fw" style="color: #fff;font-size: 2rem;"></i>
</a>
</div>
{% endif %} #}
{% else %}
<div class="item-nav">
<a href="{{ url('mypage_login') }}"><img src="{{ asset('assets/img/common/ic-user.png') }}" alt=""></a>
</div>
{% endif %}
{% set Carts = get_all_carts() %}
{% set totalPrice = get_carts_total_price() %}
{% set totalQuantity = get_carts_total_quantity() %}
<div class="ec-cartNavi">
<a href="javascript:void(0);"><img src="{{ asset('assets/img/common/ic-cart.png') }}" alt=""></a>
<span class="ec-cartNavi__badge">{{ totalQuantity|number_format }}</span>
</div>
{% if totalQuantity > 0 %}
<div class="ec-cartNaviIsset">
{% for Cart in Carts %}
{% for CartItem in Cart.CartItems %}
{% set ProductClass = CartItem.ProductClass %}
{% set Product = ProductClass.Product %}
<div class="ec-cartNaviIsset__cart">
<div class="ec-cartNaviIsset__cartDelete">
<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') }}" >
<img src="{{ asset('assets/icon/cross.svg') }}" alt="delete">
</a>
</div>
<div class="ec-cartNaviIsset__cartImage">
<img src="{{ asset(Product.MainListImage|no_image_product, 'save_image') }}" alt="{{ Product.name }}">
</div>
<div class="ec-cartNaviIsset__cartContent">
<div class="ec-cartNaviIsset__cartContentTitle">{{ Product.name }}
<div class="ec-font-size-1">
{% if ProductClass.ClassCategory1 and ProductClass.ClassCategory1.id %}
{{ ProductClass.ClassCategory1.ClassName.name }}:{{ ProductClass.ClassCategory1 }}
{% endif %}
{% if ProductClass.ClassCategory2 and ProductClass.ClassCategory2.id %}
<br>{{ ProductClass.ClassCategory2.ClassName.name }}:{{ ProductClass.ClassCategory2 }}
{% endif %}
</div>
</div>
<div class="ec-cartNaviIsset__cartContentPrice">
{{ CartItem.price|price }}
<div class="ec-cartNaviIsset__cartContentTax">{{ '税込'|trans }}</div>
</div>
<div class="ec-cartNaviIsset__cartContentNumber">{{ '数量'|trans }} {{ CartItem.quantity|number_format }}</div>
</div>
</div>
{% endfor %}
{% endfor %}
<div class="ec-cartNaviIsset__action">
<a class="ec-blockBtn--action" href="{{ url('cart') }}">{{ 'カートへ進む'|trans }}</a>
<a class="ec-blockBtn ec-cartNavi--cancel">{{ 'キャンセル'|trans }}</a>
</div>
</div>
{% else %}
<div class="ec-cartNaviNull">
<div class="ec-cartNaviNull__message">
<p>{{ '現在カート内に商品はございません。'|trans }}</p>
</div>
</div>
{% endif %}
</div>