app/template/default/Cart/index.twig line 1

Open in your IDE?
  1. {#
  2. This file is part of EC-CUBE
  3. カスタマイズTwig
  4. #}
  5. {% block javascript %}
  6.     <script>
  7.         $(function() {
  8.             {% if favorites_product_id is not empty %}
  9.                 alert("お気に入りに追加しました。");
  10.             {% endif %}
  11.             {% set current_domain = app.request.getHost() %}
  12.             {% set is_prod = 'web-order.shikomel.com' in current_domain %}
  13.             {% set is_stg = 'web-order-stg.shikomel.com' in current_domain %}
  14.             {% set custom_customer_id = is_granted('ROLE_USER') ? app.user.id:'' %}
  15.             // カート表示イベントの送付
  16.             {% if is_prod %}
  17.                 let cartData = [];
  18.                 let totalPrice = 0;
  19.                 {% for Cart in Carts %}
  20.                     {% for CartItem in Cart.CartItems %}
  21.                         {% set ProductClass = CartItem.ProductClass %}
  22.                         {% set Product = ProductClass.Product %}
  23.                         cartData.push({
  24.                             id: "{{ Product.id }}",
  25.                             name: "{{ Product.name }}",
  26.                             price: "{{ CartItem.total_price }}",
  27.                             quantity: {{ CartItem.quantity|number_format }},
  28.                         });
  29.                     {% endfor %}
  30.                     totalPrice = {{ Cart.totalPrice }};
  31.                 {% endfor %}
  32.                 if (cartData.length > 0) {
  33.                     fbq('track', 'InitiateCheckout', {
  34.                         content_type: "CartInfo",
  35.                         content_ids: cartData.map(item => item.id),
  36.                         content_name: cartData.map(item => item.name).join(", "),
  37.                         contents: cartData.map(item => ({
  38.                             id: item.id,
  39.                             name: item.name,
  40.                             quantity: item.quantity,
  41.                             price: item.price
  42.                         })),
  43.                         currency: "JPY",
  44.                         num_items: cartData.reduce((total, item) => total + item.quantity, 0),
  45.                         value: 55
  46.                     });
  47.                     // Metaへイベント送付
  48.                     fbq('trackCustom', 'ce_show_cart', {
  49.                         content_type: "CartInfo",
  50.                         content_ids: cartData.map(item => item.id),
  51.                         content_name: cartData.map(item => item.name).join(", "),
  52.                         contents: cartData.map(item => ({
  53.                             id: item.id,
  54.                             name: item.name,
  55.                             quantity: item.quantity,
  56.                             price: item.price
  57.                         })),
  58.                         currency: "JPY",
  59.                         num_items: cartData.reduce((total, item) => total + item.quantity, 0),
  60.                         value: 55
  61.                     });
  62.                     // GAへイベント送付
  63.                     window.dataLayer.push({
  64.                         event: 'ce_show_cart',
  65.                         custom_event_name: 'ce_show_cart',
  66.                         custom_contents: cartData.map(item => ({
  67.                             id: item.id,
  68.                             name: item.name,
  69.                             quantity: item.quantity,
  70.                             price: item.price
  71.                         })),
  72.                         custom_content_ids: cartData.map(item => item.id),
  73.                         custom_content_names: cartData.map(item => item.name).join(", "),
  74.                         custom_num_item: cartData.reduce((total, item) => total + item.quantity, 0),
  75.                         custom_total_price: totalPrice,
  76.                         custom_customer_id: '{{ custom_customer_id }}',
  77.                         custom_user_agent: $("#user_agent").val(),
  78.                         custom_is_ig: $("#is_ig").val(),
  79.                         custom_is_line: $("#is_line").val(),
  80.                         custom_referer: $("#referer").val(),
  81.                         custom_real_ip: $("#real_ip").val(),
  82.                     });
  83.                     // Lineへイベント送付
  84.                     _lt('send', 'cv', {
  85.                         type: 'ce_show_cart'
  86.                     },['d6fb195c-aa19-4109-8ea0-7b1d883fb349']);
  87.                 }
  88.             {% endif %}
  89.         });
  90.     </script>
  91. {% endblock %}
  92. {% extends 'default_frame.twig' %}
  93. {% set body_class = 'cart_page' %}
  94. {% block stylesheet %}
  95.     <style>
  96.     .non_product {
  97.         margin-top: 24px;
  98.         text-align: center;
  99.         font-size: 14px;
  100.         margin-bottom: 24px;
  101.     }
  102.     .non_product_continue {
  103.         margin-bottom: 0px;
  104.         border-radius: 6px;
  105.         border: solid 1px #CCCCCC;
  106.         background-color: unset;
  107.         color: #525263;
  108.         font-weight: 600;
  109.         text-align: center;
  110.         cursor: pointer;
  111.         font-size: 14px;
  112.         padding: 10px 16px;
  113.         text-decoration: none;
  114.         display: block;
  115.         height: 56px;
  116.         line-height: 56px;
  117.         padding-top: 0;
  118.         padding-bottom: 0;
  119.     }
  120.     .ec-cartRole img.minus_btn_img {
  121.         width: 32px;
  122.         height: 32px;
  123.     }
  124.     .ec-cartRole img.plus_btn_img {
  125.         width: 32px;
  126.         height: 32px;
  127.     }
  128.     .ec-cartRole .quantity {
  129.         font-size: 18px;
  130.         border-bottom: solid 2px;
  131.         width: 58px;
  132.         text-align: center;
  133.         font-weight: bold;
  134.         margin-left: 8px;
  135.         margin-right: 8px;
  136.    }
  137.     .ec-cartRow__container {
  138.         display: flex;
  139.         align-items: flex-start;
  140.     }
  141.     .ec-cart-img {
  142.         margin-right: 10px;
  143.         height: 60px;
  144.     }
  145.     .ec-cartRow__unitPrice {
  146.         font-size: 14px;
  147.     }
  148.     .ec-cart-pro-info a {
  149.         font-size: 14px;
  150.         color: #1F9FCB;
  151.         font-weight: bold;
  152.     }
  153.     .separater {
  154.         background-color: #F5F5F5;
  155.         width: 100%;
  156.     }
  157.     .ec-alert-warning .ec-alert-warning__icon img {
  158.         display: inline-block;
  159.         width: 16px;
  160.         height: 16px;
  161.     }
  162.     .ec-cartRole .ec-cartRole__error .ec-alert-warning {
  163.         max-width: 100%;
  164.         display: flex;
  165.     }
  166.     .ec-alert-warning .ec-alert-warning__text {
  167.         color: #DE5D50;
  168.         font-size: 13px;
  169.         text-align: left;
  170.         font-weight: normal;
  171.         margin-top: 4px;
  172.         width: 100%;
  173.     }
  174.     .ec-alert-warning {
  175.         margin-bottom: 24px;
  176.         background: #FFF;
  177.         border-radius: 6px;
  178.         border: solid 1px #DE5D50;
  179.         text-align: left;
  180.         display: flex;
  181.         margin-right: 20px;
  182.         margin-left: 20px;
  183.         width: auto;
  184.     }
  185.     {# PC用スタイル #}
  186.     @media screen and (min-width: 1025px) {
  187.         .ec-cartRole__error {
  188.             margin: 0 auto;
  189.             padding-left: 20px;
  190.             padding-right: 20px;
  191.             max-width: 1130px;
  192.         }
  193.         hr:not([size]) {
  194.             height: 1px;
  195.             background-color: #ddd;
  196.             opacity: 1;
  197.         }
  198.         .separater {
  199.             background-color: #DDDDDD;
  200.         }
  201.         .ec-cartRow__amountUpDown {
  202.             padding-left: 145px;
  203.         }
  204.         .ec-cart-pro-info a {
  205.             font-size: 16px;
  206.             color: #1F9FCB;
  207.         }
  208.         .ec-cart-img img {
  209.             width: 130px;
  210.             height: 105px;
  211.             max-width: 130px;
  212.             margin-right: 15px;
  213.             border-radius: 4px;
  214.         }
  215.         #form_cart_frame {
  216.             display: flex;
  217.             justify-content: space-around;
  218.         }
  219.         .ec-cartRole .ec-cartRole__cart {
  220.             padding: 0px; width: 50%; margin-left: 0px; margin-right: 100px;
  221.         }
  222.         .is_pc {
  223.             display: block;
  224.         }
  225.         .is_sp {
  226.             display: none;
  227.         }
  228.     }
  229.     {# スマホ&タブレット用スタイル #}
  230.     @media screen and (max-width: 1024px) {
  231.         hr:not([size]) {
  232.             height: 8px;
  233.             background-color: #f5f5f5;
  234.             opacity: 1;
  235.         }
  236.         .separater {
  237.             background-color: #DDDDDD;
  238.         }
  239.         .ec-cart-img {
  240.             margin-right: 10px; min-width: 74px;
  241.         }
  242.         .ec-cart-img img {
  243.             width: 74px;
  244.             height: 60px;
  245.             border-radius: 4px;
  246.         }
  247.         .is_pc {
  248.             display: none;
  249.         }
  250.         .is_sp {
  251.             display: block;
  252.         }
  253.     }
  254.     </style>
  255. {% endblock %}
  256. {% block main %}
  257.     <div class="ec-role">
  258.         <div class="ec-pageHeader">
  259.             <h1 style="border-top: none; padding: 12px 0 12px; margin-bottom: 8px;">{{ 'カート'|trans }}</h1>
  260.         </div>
  261.     </div>
  262.     {% set productStr = app.session.flashbag.get('eccube.front.request.product') %}
  263.     {% for error in app.session.flashbag.get('eccube.front.request.error') %}
  264.         {% set idx = loop.index0 %}
  265.         <div class="ec-cartRole__error">
  266.             <div class="ec-alert-warning">
  267.                 <div class="ec-alert-warning__icon"><img src="{{ asset('assets/img/common/alert_icon.png', 'user_data') }}"></div>
  268.                 <div class="ec-alert-warning__text">
  269.                     {% if productStr[idx] is defined %}
  270.                         {{ error|trans({'%product%':productStr[idx]})|nl2br }}
  271.                     {% else %}
  272.                         {{ error|trans|nl2br }}
  273.                     {% endif %}
  274.                 </div>
  275.             </div>
  276.         </div>
  277.     {% endfor %}
  278.     {% for error in app.session.flashbag.get('eccube.front.cart.error') %}
  279.         <div class="ec-cartRole__error">
  280.             <div class="ec-alert-warning">
  281.                 <div class="ec-alert-warning__icon"><img src="{{ asset('assets/img/common/alert_icon.png', 'user_data') }}"></div>
  282.                 <div class="ec-alert-warning__text">
  283.                     {{ error|trans|nl2br }}
  284.                 </div>
  285.             </div>
  286.         </div>
  287.     {% endfor %}
  288.     <div class="ec-cartRole" style="padding: 0px; display: block;">
  289.         {% if totalQuantity > 0 %}
  290.             {% if Carts|length > 1 %}
  291.                 <div class="ec-cartRole__error">
  292.                     <div class="ec-alert-warning">
  293.                         <div class="ec-alert-warning__text">
  294.                             {{ '同時購入できない商品がカートに含まれています。'|trans|nl2br }}
  295.                         </div>
  296.                     </div>
  297.                 </div>
  298.             {% endif %}
  299.             <form name="form" id="form_cart" method="post" action="{{ url('cart') }}">
  300.                 {% for CartIndex,Cart in Carts %}
  301.                     {% set cartKey = Cart.cart_key %}
  302.                     {% for error in app.session.flashbag.get('eccube.front.cart.' ~ cartKey ~ '.request.error') %}
  303.                     <div class="ec-cartRole__error">
  304.                         <div class="ec-alert-warning">
  305.                             <div class="ec-alert-warning__icon"><img src="{{ asset('assets/img/common/alert_icon.png', 'user_data') }}"></div>
  306.                             <div class="ec-alert-warning__text">
  307.                                 {{ error|trans|nl2br }}
  308.                             </div>
  309.                         </div>
  310.                     </div>
  311.                     {% endfor %}
  312.                 <div id="form_cart_frame">
  313.                     <div class="ec-cartRole__cart" style="">
  314.                         <div class="">
  315.                             {% for CartItem in Cart.CartItems %}
  316.                                 {% set ProductClass = CartItem.ProductClass %}
  317.                                 {% set Product = ProductClass.Product %}
  318.                                 <div style="padding-right: 16px; padding-left: 16px;">
  319.                                     <div style="margin-top: 20px;">
  320.                                         <div class="ec-cartRow__container" style="display: flex; align-items: flex-start;">
  321.                                             <div class="ec-cart-img" style="">
  322.                                                 <a target="_blank" href="{{ url('product_detail', {id : Product.id} ) }}">
  323.                                                     <img src="{{ asset(Product.MainListImage|no_image_product, 'save_image') }}" alt="{{ Product.name }}"/>
  324.                                                 </a>
  325.                                             </div>
  326.                                             <div class="ec-cart-pro-info">
  327.                                                 <div class="ec-cartRow__name" style="line-height: 1.2;  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;">
  328.                                                     <a target="_blank" style="" href="{{ url('product_detail', {id : Product.id} ) }}">
  329.                                                         {{ Product.name }}
  330.                                                     </a>
  331.                                                 </div>
  332.                                                 <div class="ec-cartRow__unitPrice" style="margin-top: 5px;">{{ CartItem.price|number_format }}円
  333.                                                 {% if Product.standard_text %}({{ Product.standard_text }}){% endif %}
  334.                                                 </div>
  335.                                             </div>
  336.                                         </div>
  337.                                     </div>
  338.                                     <div style="display: flex; margin-top: 8px; 
  339.                                     {% if not CartItem.ProductClass.Product.is_recipe_book %} 
  340.                                         justify-content: space-between; 
  341.                                     {% else %}
  342.                                         justify-content: end; 
  343.                                     {% endif %}
  344.                                     align-items: flex-end;">
  345.                                         {# レシピ帖の場合には数量のアップダウンは非表示 #}
  346.                                         {% if not CartItem.ProductClass.Product.is_recipe_book %}
  347.                                         <div class="ec-cartRow__amountUpDown" style="display: flex;">
  348.                                             {% if CartItem.quantity > 1 %}
  349.                                                 <a class="plus_btn" 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">
  350.                                                     <span class="ec-cartRow__amountDownButton__icon">
  351.                                                         <img src="{{ asset('assets/img/common/minus_btn.png', 'user_data') }}" alt="reduce" class="minus_btn_img">
  352.                                                     </span>
  353.                                                 </a>
  354.                                             {% else %}
  355.                                                 <div class="ec-cartRow__amountDownButtonDisabled">
  356.                                                     <span class="ec-cartRow__amountDownButton__icon">
  357.                                                         <img src="{{ asset('assets/img/common/minus_btn_disabled.png', 'user_data') }}" alt="reduce" class="minus_btn_img">
  358.                                                     </span>
  359.                                                 </div>
  360.                                             {% endif %}
  361.                                             <div class="quantity">{{ CartItem.quantity|number_format }}</div>
  362.                                             <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">
  363.                                                 <span class="ec-cartRow__amountUpButton__icon">
  364.                                                     <img src="{{ asset('assets/img/common/plus_btn.png', 'user_data') }}" alt="increase" class="plus_btn_img">
  365.                                                 </span>
  366.                                             </a>
  367.                                         </div>
  368.                                         {% endif %}
  369.                                         <div class="ec-cartRow__sutbtotalSP">
  370.                                             <span style="font-size: 14px;">小計</span>
  371.                                             <span style="font-size: 20px; font-weight: bold;">{{ CartItem.total_price|number_format }}</span>
  372.                                             <span style="font-size: 14px;">円</span>
  373.                                             <span style="font-size: 14px;">(税込)</span>
  374.                                         </div>
  375.                                     </div>
  376.                                     <div style="text-align: right; margin-top: 14px;">
  377.                                         {% if is_granted('ROLE_USER') %}
  378.                                             <a href="{{ url('product_add_favorite', {id:Product.id}) }}" class="ec-icon" data-method="post">
  379.                                                 <span style="font-size: 14px; text-decoration: underline; color: #525263; margin-right: 20px;">お気に入りに追加</span>
  380.                                             </a>
  381.                                         {% endif %}
  382.                                         <a href="{{ url('cart_handle_item', {'operation': 'remove', 'productClassId': ProductClass.id }) }}" {{ csrf_token_for_anchor() }} class="ec-icon" data-method="put" data-message="カートから商品を削除してもよろしいですか?">
  383.                                             <span style="font-size: 14px; text-decoration: underline; color: #525263;">削除</span>
  384.                                         </a>
  385.                                     </div>
  386.                                 </div>
  387.                                 <hr class="separater" style="">
  388.                             {% endfor %}
  389.                         </div>
  390.                     </div>
  391.                     <div class="ec-cartRole__actions" style="padding-right: 16px; padding-left: 16px; margin-right: 0px; width: 375px;">
  392.                         <div style="position: sticky; top: 50px;">
  393.                             <div class="ec-cartRole__total" style="display: flex; justify-content: space-between; align-items: center; height: 36px; margin: 16px 0px; padding: 0px;">
  394.                                 <span style="font-size: 18px; font-weight: bold;">
  395.                                     合計金額<span style="font-size: 14px; font-weight: normal;">({{ Cart.CartItems|length }}商品)</span>
  396.                                 </span>
  397.                                 <span class="ec-cartRole__totalAmount" style="font-size: 24px; font-weight: bold;">
  398.                                     {{ Cart.totalPrice|number_format }}
  399.                                     <span style="font-size: 14px; font-weight: bold;">円(税込)</span>
  400.                                 </span>
  401.                             </div>
  402.                             {# PCもSPもクーポンあればバナー表示するように修正 #}
  403.                             {% if isShowCouponCode is defined and isShowCouponCode %}
  404.                                 <div class="" style="margin: auto;">
  405.                                     <img src="{{ asset('assets/img/common/has_3000_coupon_cart.png', 'user_data') }}" style="padding: 0px 10px;">
  406.                                 </div>
  407.                             {% endif %}
  408.                             <a class="ec-blockBtn--action" style="max-width: 343px; margin: auto; background-color: #DE5D50; border-color: #DE5D50;" href="{{ url('shopping_nonmember') }}">{{ 'ご注文手続きへ'|trans }}</a>
  409.                             {% if loop.last %}
  410.                                 <div style="text-align: center; margin-bottom: 16px; margin-top: 16px; line-height: 39px;">
  411.                                     <a style="color: #1F9FCB;" href="{{ path('homepage') }}">{{ 'お買い物を続ける'|trans }}</a>
  412.                                 </div>
  413.                             {% endif %}
  414.                         </div>
  415.                     </div>
  416.                 {% endfor %}
  417.                 </div>
  418.             </form>
  419.         {% else %}
  420.             {% for CartIndex,Cart in Carts %}
  421.                 {% set cartKey = Cart.cart_key %}
  422.                 {% for error in app.session.flashbag.get('eccube.front.cart.' ~ cartKey ~ '.request.error') %}
  423.                     <div class="ec-cartRole__error">
  424.                         <div class="ec-alert-warning">
  425.                             <div class="ec-alert-warning__icon"><img src="{{ asset('assets/icon/exclamation-white.svg') }}"></div>
  426.                             <div class="ec-alert-warning__text">
  427.                                 {{ error|trans|nl2br }}
  428.                             </div>
  429.                         </div>
  430.                     </div>
  431.                 {% endfor %}
  432.             {% endfor %}
  433.             <div class="ec-role">
  434.                 <div class="ec-off3Grid">
  435.                     <div class="ec-off3Grid__cell">
  436.                         <div class="non_product">{{ 'カートに商品がありません。'|trans }}</div>
  437.                         <div style="margin-bottom: 24px;">
  438.                             <a class="non_product_continue" href="{{ path('homepage') }}">{{ 'お買い物を続ける'|trans }}</a>
  439.                         </div>
  440.                     </div>
  441.                 </div>
  442.             </div>
  443.         {% endif %}
  444.     </div>
  445. {% endblock %}