{#
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.
#}
{% extends 'default_frame.twig' %}
{% set body_class = 'cart_page' %}
{% block stylesheet %}
<link rel="stylesheet" href="{{ asset('assets/css/cart.css') }}">
{% endblock %}
{% block javascript %}
<script>
loadingOverlay('show');
$(function() {
// Khôi phục vị trí scroll sau khi reload
var scrollPosition = sessionStorage.getItem('cartScrollPosition');
if (scrollPosition) {
// Sử dụng setTimeout để đảm bảo DOM đã load xong
setTimeout(function() {
$(window).scrollTop(parseInt(scrollPosition), 'fast');
sessionStorage.removeItem('cartScrollPosition');
}, 100);
}
// Lưu vị trí scroll trước khi submit form cho nút tăng/giảm số lượng
$(document).on('click', '.cart-item__quantity-btn--plus, .cart-item__quantity-btn--minus', function(e) {
// Chỉ xử lý nếu là link (có href), không phải span disabled
if ($(this).is('a')) {
// Lưu vị trí scroll hiện tại vào sessionStorage
sessionStorage.setItem('cartScrollPosition', $(window).scrollTop());
}
});
});
</script>
{% endblock %}
{% block main %}
<!-- breadcrumb section -->
<div class="breadcrumb-section">
<div class="container-1360 border-box px-40">
<nav class="breadcrumb" aria-label="パンくずリスト">
<a href="{{ url('homepage') }}" class="breadcrumb__item">ホーム</a>
<img class="breadcrumb__separator" src="{{ asset('assets/img/default/icons/icon-breadcrumb-separator.svg') }}" alt="" width="12" height="12" />
<span class="breadcrumb__item breadcrumb__item--current">カート</span>
</nav>
</div>
</div>
<div class="container-1200-fix">
<!-- title -->
<div class="base-title">
<img class="base-title__icon" src="{{ asset('assets/img/default/icons/icon-title.png') }}" alt="" width="48" height="48" />
<h1 class="base-title__text">カート</h1>
</div>
{% set productStr = app.session.flashbag.get('eccube.front.request.product') %}
{% for error in app.session.flashbag.get('eccube.front.request.error') %}
{% set idx = loop.index0 %}
<div class="ec-cartRole__error">
<div class="ec-alert-warning">
<div class="ec-alert-warning__icon"><img src="{{ asset('assets/icon/exclamation-white.svg') }}"></div>
<div class="ec-alert-warning__text">
{% if productStr[idx] is defined %}
{{ error|trans({'%product%':productStr[idx]})|nl2br }}
{% else %}
{{ error|trans|nl2br }}
{% endif %}
</div>
</div>
</div>
{% endfor %}
{% for error in app.session.flashbag.get('eccube.front.cart.error') %}
<div class="ec-cartRole__error">
<div class="ec-alert-warning">
<div class="ec-alert-warning__icon"><img src="{{ asset('assets/icon/exclamation-white.svg') }}"></div>
<div class="ec-alert-warning__text">
{{ error|trans|nl2br }}
</div>
</div>
</div>
{% endfor %}
{% if totalQuantity > 0 %}
{% if Carts|length > 1 %}
<div class="ec-cartRole__error">
<div class="ec-alert-warning">
<div class="ec-alert-warning__text">
{{ 'front.cart.divide_cart'|trans|nl2br }}
</div>
</div>
</div>
{% endif %}
<form name="form" id="form_cart" method="post" action="{{ url('cart') }}">
{% for CartIndex,Cart in Carts %}
{% set cartKey = Cart.cart_key %}
{% for error in app.session.flashbag.get('eccube.front.cart.' ~ cartKey ~ '.request.error') %}
<div class="ec-cartRole__error">
<div class="ec-alert-warning">
<div class="ec-alert-warning__icon"><img src="{{ asset('assets/icon/exclamation-white.svg') }}"></div>
<div class="ec-alert-warning__text">
{{ error|trans|nl2br }}
</div>
</div>
</div>
{% endfor %}
<!-- content -->
<div class="cart-wrapper">
<div class="cart-items">
{% for CartItem in Cart.CartItems %}
{% set ProductClass = CartItem.ProductClass %}
{% set Product = ProductClass.Product %}
<div class="cart-item">
<a href="{{ url('cart_handle_item', {'operation': 'remove', 'productClassId': ProductClass.id }) }}" {{ csrf_token_for_anchor() }} class="cart-item__delete" data-method="put" data-message="カートから商品を削除してもよろしいですか?">
<img class="cart-item__delete-icon" src="{{ asset('assets/img/default/icons/icon-trash.svg') }}" alt="" />
<span>削除</span>
</a>
<a class="cart-item__image" target="_blank" href="{{ url('product_detail', {id : Product.id} ) }}">
<img class="cart-item__image" src="{{ asset(Product.MainListImage|no_image_product, 'save_image') }}" alt="{{ Product.name }}" width="211" height="158" />
</a>
<div class="cart-item__info">
<div class="cart-item__details">
<div class="cart-item__label">商品名</div>
<div class="cart-item__name">
<a target="_blank" href="{{ url('product_detail', {id : Product.id} ) }}" class="text-black">{{ Product.name }}</a>
{% if ProductClass.ClassCategory1 and ProductClass.ClassCategory1.id %}
<div>{{ ProductClass.ClassCategory1.ClassName.name }}:{{ ProductClass.ClassCategory1 }}</div>
{% endif %}
{% if ProductClass.ClassCategory2 and ProductClass.ClassCategory2.id %}
<div>{{ ProductClass.ClassCategory2.ClassName.name }}:{{ ProductClass.ClassCategory2 }}</div>
{% endif %}
</div>
<div class="cart-item__price">
{{ CartItem.price|price }}
{% if ProductClass.getPrice02 %}
<span class="cart-item__price-tax">(税抜 {{ ProductClass.getPrice02|price }})</span>
{% endif %}
</div>
</div>
<div class="cart-item__info-wrapper">
<div class="cart-item__quantity-section">
<div class="cart-item__label">数量</div>
<div class="cart-item__quantity">
{% if CartItem.quantity > 1 %}
<a href="{{ url('cart_handle_item', {'operation': 'down', 'productClassId': ProductClass.id}) }}" {{ csrf_token_for_anchor() }} class="cart-item__quantity-btn cart-item__quantity-btn--minus load-overlay" data-method="put" data-confirm="false">−</a>
{% else %}
<span class="cart-item__quantity-btn cart-item__quantity-btn--minus" style="opacity: 0.5; cursor: not-allowed;">−</span>
{% endif %}
<span class="cart-item__quantity-value">{{ CartItem.quantity|number_format }}</span>
<a href="{{ url('cart_handle_item', {'operation': 'up', 'productClassId': ProductClass.id}) }}" {{ csrf_token_for_anchor() }} class="cart-item__quantity-btn cart-item__quantity-btn--plus load-overlay" data-method="put" data-confirm="false">+</a>
</div>
</div>
<div class="cart-item__subtotal-section">
<div class="cart-item__label">小計</div>
<div class="cart-item__subtotal">
<span>{{ CartItem.total_price|price }}</span>
<span class="cart-item__subtotal-tax">(税込)</span>
</div>
</div>
</div>
</div>
</div>
{% endfor %}
</div>
<div class="cart-summary">
<div class="cart-summary__inner_1">
<div class="cart-summary__row">
<div class="cart-summary__label">数量</div>
<div class="cart-summary__value">{{ Cart.totalQuantity|number_format }}</div>
</div>
<div class="cart-summary__row">
<div class="cart-summary__label">商品合計(税込)</div>
<div class="cart-summary__value">{{ Cart.totalPrice|price }}</div>
</div>
</div>
<div class="cart-summary__inner_2">
<div class="cart-summary__note">
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M10 1C14.9706 1 19 5.02944 19 10C19 14.9706 14.9706 19 10 19C5.02944 19 1 14.9706 1 10C1 5.02944 5.02944 1 10 1ZM9.03516 11.7783L6.20703 8.9502L4.79297 10.3643L9.03516 14.6064L15.3994 8.24219L13.9854 6.82812L9.03516 11.7783Z" fill="#353535"/>
</svg>
<span>ご注文手続きに進みます</span>
</div>
<a href="{{ path('cart_buystep', {'cart_key':cartKey}) }}" class="cart-summary__checkout">
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M6 18C5.46957 18 4.96086 18.2107 4.58579 18.5858C4.21071 18.9609 4 19.4696 4 20C4 20.5304 4.21071 21.0391 4.58579 21.4142C4.96086 21.7893 5.46957 22 6 22C6.53043 22 7.03914 21.7893 7.41421 21.4142C7.78929 21.0391 8 20.5304 8 20C8 18.89 7.11 18 6 18ZM22 2H18.73L17.79 4H3C2.73478 4 2.48043 4.10536 2.29289 4.29289C2.10536 4.48043 2 4.73478 2 5C2 5.17 2.05 5.34 2.12 5.5L5.7 11.97C6.04 12.58 6.7 13 7.45 13H14.9L15.8 14.63L15.83 14.75C15.83 14.8163 15.8037 14.8799 15.7568 14.9268C15.7099 14.9737 15.6463 15 15.58 15H4V17H16C16.5304 17 17.0391 16.7893 17.4142 16.4142C17.7893 16.0391 18 15.5304 18 15C18 14.65 17.91 14.32 17.76 14.04L16.4 11.59L20 4H22V2ZM16 18C15.4696 18 14.9609 18.2107 14.5858 18.5858C14.2107 18.9609 14 19.4696 14 20C14 20.5304 14.2107 21.0391 14.5858 21.4142C14.9609 21.7893 15.4696 22 16 22C16.5304 22 17.0391 21.7893 17.4142 21.4142C17.7893 21.0391 18 20.5304 18 20C18 18.89 17.11 18 16 18ZM7 11L4.22 6H16.86L14.5 11H7Z" fill="#F5F5F5"/>
</svg>
<span>お会計に進む</span>
<svg class="cart-summary__checkout-icon" width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<rect width="24" height="24" rx="8" fill="#F5F5F5"/>
<path d="M10.112 6.99379L13.1667 10.0485C14.2914 11.1732 14.2914 12.9967 13.1667 14.1214L10.112 17.1761" stroke="#353535" stroke-width="1.35"/>
</svg>
</a>
</div>
</div>
</div>
{% if BaseInfo.delivery_free_amount and BaseInfo.delivery_free_quantity %}
<div class="ec-cartRole__progress">
{% if is_delivery_free[cartKey] %}
{{ 'front.cart.delivery_fee_free__now'|trans }}
{% else %}
{{ 'front.cart.delivery_fee_free__price_and_quantity'|trans({ '%price%': least[cartKey]|price, '%quantity%': quantity[cartKey]|number_format })|raw }}
{% endif %}
</div>
{% elseif BaseInfo.delivery_free_amount %}
<div class="ec-cartRole__progress">
{% if is_delivery_free[cartKey] %}
{{ 'front.cart.delivery_fee_free__now'|trans }}
{% else %}
{{ 'front.cart.delivery_fee_free__price'|trans({ '%price%': least[cartKey]|price })|raw }}
{% endif %}
</div>
{% elseif BaseInfo.delivery_free_quantity %}
<div class="ec-cartRole__progress">
{% if is_delivery_free[cartKey] %}
{{ 'front.cart.delivery_fee_free__now'|trans }}
{% else %}
{{ 'front.cart.delivery_fee_free__quantity'|trans({ '%quantity%': quantity[cartKey]|number_format })|raw }}
{% endif %}
</div>
{% endif %}
{% endfor %}
{# {{ form_rest(form) }} #}
</form>
{% else %}
{% for CartIndex,Cart in Carts %}
{% set cartKey = Cart.cart_key %}
{% for error in app.session.flashbag.get('eccube.front.cart.' ~ cartKey ~ '.request.error') %}
<div class="ec-cartRole__error">
<div class="ec-alert-warning">
<div class="ec-alert-warning__icon"><img src="{{ asset('assets/icon/exclamation-white.svg') }}"></div>
<div class="ec-alert-warning__text">
{{ error|trans|nl2br }}
</div>
</div>
</div>
{% endfor %}
{% endfor %}
<div class="ec-role">
<div class="ec-off3Grid">
<div class="ec-off3Grid__cell">
<div class="ec-alert-warning">
<div class="ec-alert-warning__icon"><img src="{{ asset('assets/icon/exclamation-white.svg') }}"></div>
<div class="ec-alert-warning__text">{{ 'front.cart.no_items'|trans }}</div>
</div>
</div>
</div>
</div>
{% endif %}
</div>
{% endblock %}