app/template/default/Cart/index.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. {% extends 'default_frame.twig' %}
  9. {% set body_class = 'cart_page' %}
  10. {% block javascript %}
  11. <script>
  12. // eコマースadd_to_cartイベント
  13. dataLayer.push({ecommerce: null});  // Clear the previous ecommerce object.
  14. // GA4
  15. dataLayer.push({
  16.     'event': 'test_add_to_cart',
  17.     'ecommerce': {
  18.         'items': [
  19.             {% for CartIndex,Cart in Carts %}
  20.             {% for CartItem in Cart.CartItems %}
  21.             {% set ProductClass = CartItem.ProductClass %}
  22.             {% set Product = ProductClass.Product %}
  23.             {
  24.                 'item_name': '{{ Product.name }}',
  25.                 'item_id': '{{ Product.getCodeMin ? Product.getCodeMin : Product.id }}',
  26.                 'price': '{{ Product.getPrice02IncTaxMin }}'
  27.             }{% if not loop.last %},{% endif %}
  28.             {% endfor %}
  29.             {% endfor %}
  30.         ]
  31.     }
  32. });
  33. </script>
  34. {% endblock %}
  35. {% block main %}
  36. <style>
  37. @media (max-width: 767px) {
  38.     .ec-cartRow{
  39.         display: flex;
  40.         align-items: center;
  41.         flex-wrap: wrap;
  42.         box-sizing: border-box;
  43.         font-size:14px;
  44.     }
  45.     ul.ec-cartRow{
  46.         padding-left:0;
  47.     }
  48.     .ec-cartRow .ec-cartRow__delColumn{
  49.         width:10%;
  50.         margin:0;
  51.         display:block;
  52.         border-bottom:none;
  53.             }
  54.     .ec-cartRow .ec-cartRow__contentColumn{
  55.         width:90%;
  56.         margin:0;
  57.         display:block;
  58.         order:-1;
  59.         border-bottom:none;
  60.     }
  61.     .ec-cartRow .ec-cartRow__amountColumn{
  62.         width:100%;
  63.         padding:0 0 10px;
  64.         display:flex;
  65.         align-items: center;
  66.         justify-content:center;
  67.         text-align:center;
  68.     }
  69.     .ec-cartRow .ec-cartRow__amountColumn .ec-cartRow__amountUpDown {
  70.       justify-content: center;
  71.     }
  72.     .ec-cartRow .ec-cartRow__amountColumn .ec-cartRow__amountSP{
  73.         margin-bottom:0;
  74.         margin-right:10px;
  75.     }
  76.     .ec-cartRow .ec-cartRow__img{
  77.         width:20%;
  78.     }
  79.     .ec-cartRow .ec-cartRow__summary{
  80.         width:75%;
  81.     }
  82. }
  83. </style>
  84.     <div class="ec-role">
  85.         <div class="ec-pageHeader">
  86.             <h1>{{ 'ショッピングカート'|trans }}</h1>
  87.         </div>
  88.     </div>
  89.     <div class="ec-cartRole">
  90.         <div class="ec-cartRole__progress">
  91.             <ul class="ec-progress">
  92.                 {% set step = 1 %}
  93.                 <li class="ec-progress__item is-complete">
  94.                     <div class="ec-progress__number">{{ step }}{% set step = step + 1 %}
  95.                     </div>
  96.                     <div class="ec-progress__label">{{ 'カートの商品'|trans }}
  97.                     </div>
  98.                 </li>
  99.                 {% if is_granted('ROLE_USER') == false %}
  100.                     <li class="ec-progress__item">
  101.                         <div class="ec-progress__number">{{ step }}{% set step = step + 1 %}
  102.                         </div>
  103.                         <div class="ec-progress__label">{{ 'お客様情報'|trans }}
  104.                         </div>
  105.                     </li>
  106.                 {% endif %}
  107.                 <li class="ec-progress__item">
  108.                     <div class="ec-progress__number">{{ step }}{% set step = step + 1 %}
  109.                     </div>
  110.                     <div class="ec-progress__label">{{ 'ご注文手続き'|trans }}
  111.                     </div>
  112.                 </li>
  113.                 <li class="ec-progress__item">
  114.                     <div class="ec-progress__number">{{ step }}{% set step = step + 1 %}
  115.                     </div>
  116.                     <div class="ec-progress__label">{{ 'ご注文内容確認'|trans }}
  117.                     </div>
  118.                 </li>
  119.                 <li class="ec-progress__item">
  120.                     <div class="ec-progress__number">{{ step }}{% set step = step + 1 %}
  121.                     </div>
  122.                     <div class="ec-progress__label">{{ '完了'|trans }}
  123.                     </div>
  124.                 </li>
  125.             </ul>
  126.         </div>
  127.         {% set productStr = app.session.flashbag.get('eccube.front.request.product') %}
  128.         {% for error in app.session.flashbag.get('eccube.front.request.error') %}
  129.             {% set idx = loop.index0 %}
  130.             <div class="ec-cartRole__error">
  131.                 <div class="ec-alert-warning">
  132.                     <div class="ec-alert-warning__icon"><img src="{{ asset('assets/icon/exclamation-white.svg') }}"></div>
  133.                     <div class="ec-alert-warning__text">
  134.                         {% if productStr[idx] is defined %}
  135.                             {{ error|trans({'%product%':productStr[idx]})|nl2br }}
  136.                         {% else %}
  137.                             {{ error|trans|nl2br }}
  138.                         {% endif %}
  139.                     </div>
  140.                 </div>
  141.             </div>
  142.         {% endfor %}
  143.         {% for error in app.session.flashbag.get('eccube.front.cart.error') %}
  144.             <div class="ec-cartRole__error">
  145.                 <div class="ec-alert-warning">
  146.                     <div class="ec-alert-warning__icon"><img src="{{ asset('assets/icon/exclamation-white.svg') }}"></div>
  147.                     <div class="ec-alert-warning__text">
  148.                         {{ error|trans|nl2br }}
  149.                     </div>
  150.                 </div>
  151.             </div>
  152.         {% endfor %}
  153.         {% if totalQuantity > 0 %}
  154.             <div class="ec-cartRole__totalText">
  155.                 <p>
  156.                     {{ '商品の合計金額は「<strong>%price%</strong>」です。'|trans({ '%price%': totalPrice|price })|raw }}
  157.                 </p>
  158.             </div>
  159.             {% if Carts|length > 1 %}
  160.                 <div class="ec-cartRole__error">
  161.                     <div class="ec-alert-warning">
  162.                         <div class="ec-alert-warning__text">
  163.                             {{ '同時購入できない商品がカートに含まれています。'|trans|nl2br }}
  164.                         </div>
  165.                     </div>
  166.                 </div>
  167.             {% endif %}
  168.             <form name="form" id="form_cart" class="ec-cartRole" method="post" action="{{ url('cart') }}">
  169.                 {% for CartIndex,Cart in Carts %}
  170.                     {% set cartKey = Cart.cart_key %}
  171.                     {% for error in app.session.flashbag.get('eccube.front.cart.' ~ cartKey ~ '.request.error') %}
  172.                         <div class="ec-cartRole__error">
  173.                             <div class="ec-alert-warning">
  174.                                 <div class="ec-alert-warning__icon"><img src="{{ asset('assets/icon/exclamation-white.svg') }}"></div>
  175.                                 <div class="ec-alert-warning__text">
  176.                                     {{ error|trans|nl2br }}
  177.                                 </div>
  178.                             </div>
  179.                         </div>
  180.                     {% endfor %}
  181.                     <div class="ec-cartRole__cart">
  182.                         <div class="ec-cartTable">
  183.                             <ol class="ec-cartHeader">
  184.                                 <li class="ec-cartHeader__label">{{ '削除'|trans }}</li>
  185.                                 <li class="ec-cartHeader__label">{{ '商品内容'|trans }}</li>
  186.                                 <li class="ec-cartHeader__label">{{ '数量'|trans }}</li>
  187.                                 <li class="ec-cartHeader__label">{{ '小計'|trans }}</li>
  188.                             </ol>
  189.                             {% for CartItem in Cart.CartItems %}
  190.                                 {% set ProductClass = CartItem.ProductClass %}
  191.                                 {% set Product = ProductClass.Product %}
  192.                                 <ul class="ec-cartRow">
  193.                                     <li class="ec-cartRow__delColumn">
  194.                                         <a href="{{ url('cart_handle_item', {'operation': 'remove', 'productClassId': ProductClass.id }) }}" {{ csrf_token_for_anchor() }} class="ec-icon" data-method="put" data-message="カートから商品を削除してもよろしいですか?">
  195.                                             <img src="{{ asset('assets/icon/cross.svg') }}" alt="delete">
  196.                                         </a>
  197.                                     </li>
  198.                                     <li class="ec-cartRow__contentColumn">
  199.                                         <div class="ec-cartRow__img">
  200.                                             <a target="_blank" href="{{ url('product_detail', {id : Product.id} ) }}">
  201.                                                 <img src="{{ asset(Product.MainListImage|no_image_product, 'save_image') }}" alt="{{ Product.name }}"/>
  202.                                             </a>
  203.                                         </div>
  204.                                         <div class="ec-cartRow__summary">
  205.                                             <div class="ec-cartRow__name">
  206.                                                 <a target="_blank" href="{{ url('product_detail', {id : Product.id} ) }}">{{ Product.name }}</a>
  207.                                                 {% if ProductClass.ClassCategory1 and ProductClass.ClassCategory1.id %}
  208.                                                     <br>{{ ProductClass.ClassCategory1.ClassName.name }}:{{ ProductClass.ClassCategory1 }}
  209.                                                 {% endif %}
  210.                                                 {% if ProductClass.ClassCategory2 and ProductClass.ClassCategory2.id %}
  211.                                                     <br>{{ ProductClass.ClassCategory2.ClassName.name }}:{{ ProductClass.ClassCategory2 }}
  212.                                                 {% endif %}
  213.                                             </div>
  214.                                             <div class="ec-cartRow__unitPrice">{{ CartItem.price|price }}</div>
  215.                                             <div class="ec-cartRow__sutbtotalSP">{{ '小計:'|trans }}{{ CartItem.total_price|price }}</div>
  216.                                         </div>
  217.                                     </li>
  218.                                     <li class="ec-cartRow__amountColumn">
  219.                                         <div class="ec-cartRow__amount">{{ CartItem.quantity|number_format }}</div>
  220.                                         <div class="ec-cartRow__amountSP">{{ '数量:'|trans }}{{ CartItem.quantity|number_format }}</div>
  221.                                         <div class="ec-cartRow__amountUpDown">
  222.                                             {% if CartItem.quantity > 1 %}
  223.                                                 <a href="{{ url('cart_handle_item', {'operation': 'down', 'productClassId': ProductClass.id}) }}" {{ csrf_token_for_anchor() }} class="ec-cartRow__amountDownButton load-overlay" data-method="put" data-confirm="false">
  224.                                                     <span class="ec-cartRow__amountDownButton__icon"><img src="{{ asset('assets/icon/minus-dark.svg') }}" alt="reduce"></span>
  225.                                                 </a>
  226.                                             {% else %}
  227.                                                 <div class="ec-cartRow__amountDownButtonDisabled">
  228.                                                     <span class="ec-cartRow__amountDownButton__icon"><img src="{{ asset('assets/icon/minus.svg') }}" alt="reduce"></span>
  229.                                                 </div>
  230.                                             {% endif %}
  231.                                             <a href="{{ url('cart_handle_item', {'operation': 'up', 'productClassId': ProductClass.id}) }}" {{ csrf_token_for_anchor() }} class="ec-cartRow__amountUpButton load-overlay" data-method="put" data-confirm="false">
  232.                                                 <span class="ec-cartRow__amountUpButton__icon"><img src="{{ asset('assets/icon/plus-dark.svg') }}" alt="increase"></span>
  233.                                             </a>
  234.                                         </div>
  235.                                     </li>
  236.                                     <li class="ec-cartRow__subtotalColumn">
  237.                                         <div class="ec-cartRow__sutbtotal">{{ CartItem.total_price|price }}</div>
  238.                                     </li>
  239.                                 </ul>
  240.                             {% endfor %}
  241.                         </div>
  242.                     </div>
  243.                     <div class="ec-cartRole__progress">
  244.                         {% if BaseInfo.delivery_free_amount and BaseInfo.delivery_free_quantity %}
  245.                             <br/>
  246.                             {% if is_delivery_free[cartKey] %}
  247.                                 {{ '現在送料無料です。'|trans }}
  248.                             {% else %}
  249.                                 {{ 'あと「<strong>%price%</strong>」または「<strong>%quantity%個</strong>」のお買い上げで<strong class="ec-color-red">送料無料</strong>になります。'|trans({ '%price%': least[cartKey]|price, '%quantity%': quantity[cartKey]|number_format })|raw }}
  250.                             {% endif %}
  251.                         {% elseif BaseInfo.delivery_free_amount %}
  252.                             <br/>
  253.                             {% if is_delivery_free[cartKey] %}
  254.                                 {{ '現在送料無料です。'|trans }}
  255.                             {% else %}
  256.                                 {{ 'あと「<strong>%price%</strong>」のお買い上げで<strong class="ec-color-red">送料無料</strong>になります。'|trans({ '%price%': least[cartKey]|price })|raw }}
  257.                             {% endif %}
  258.                         {% elseif BaseInfo.delivery_free_quantity %}
  259.                             <br/>
  260.                             {% if is_delivery_free[cartKey] %}
  261.                                 {{ '現在送料無料です。'|trans }}
  262.                             {% else %}
  263.                                 {{ 'あと「<strong>%quantity%個</strong>」のお買い上げで<strong class="ec-color-red">送料無料</strong>になります。'|trans({ '%quantity%': quantity[cartKey]|number_format })|raw }}
  264.                             {% endif %}
  265.                         {% endif %}
  266.                     </div>
  267.                     <div class="ec-cartRole__actions">
  268.                         <div class="ec-cartRole__total">{{ '合計:'|trans }}<span class="ec-cartRole__totalAmount">{{ Cart.totalPrice|price }}</span>
  269.                         </div>
  270.                         <a class="ec-blockBtn--action" href="{{ path('cart_buystep', {'cart_key':cartKey}) }}">{{ 'レジに進む'|trans }}</a>
  271.                         {% if loop.last %}
  272.                             <a class="ec-blockBtn--cancel" href="{{ path('homepage') }}">{{ 'お買い物を続ける'|trans }}</a>
  273.                         {% endif %}
  274.                     </div>
  275.                 {% endfor %}
  276.             </form>
  277.         {% else %}
  278.             {% for CartIndex,Cart in Carts %}
  279.                 {% set cartKey = Cart.cart_key %}
  280.                 {% for error in app.session.flashbag.get('eccube.front.cart.' ~ cartKey ~ '.request.error') %}
  281.                     <div class="ec-cartRole__error">
  282.                         <div class="ec-alert-warning">
  283.                             <div class="ec-alert-warning__icon"><img src="{{ asset('assets/icon/exclamation-white.svg') }}"></div>
  284.                             <div class="ec-alert-warning__text">
  285.                                 {{ error|trans|nl2br }}
  286.                             </div>
  287.                         </div>
  288.                     </div>
  289.                 {% endfor %}
  290.             {% endfor %}
  291.             <div class="ec-role">
  292.                 <div class="ec-off3Grid">
  293.                     <div class="ec-off3Grid__cell">
  294.                         <div class="ec-alert-warning">
  295.                             <div class="ec-alert-warning__icon"><img src="{{ asset('assets/icon/exclamation-white.svg') }}"></div>
  296.                             <div class="ec-alert-warning__text">{{ '現在カート内に商品はございません。'|trans }}</div>
  297.                         </div>
  298.                     </div>
  299.                 </div>
  300.             </div>
  301.         {% endif %}
  302.     </div>
  303. {% endblock %}