app/template/BlackCherry/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 = 'front_page' %}
  10. {% block stylesheet %}
  11.     <style>
  12.         .main_visual {
  13.             text-align: center;
  14.             margin: 0 auto;
  15.             padding-left: 20px;
  16.             padding-right: 20px;
  17.         }
  18.         .main_visual img {
  19.             width: 100%;
  20.             height: auto;
  21.             max-width: 100%;
  22.         }
  23.         @media only screen and (min-width: 768px) {
  24.             .main_visual img {
  25.                 width: 80%;
  26.                 margin: auto;
  27.             }
  28.         }
  29.         /* モバイルでのLCP最適化 */
  30.         @media only screen and (max-width: 767px) {
  31.             .main_visual img {
  32.                 width: 100%;
  33.                 height: auto;
  34.                 object-fit: cover;
  35.             }
  36.         }
  37.         .slick-slider {
  38.             margin-bottom: 30px;
  39.         }
  40.         .slick-dots {
  41.             position: absolute;
  42.             bottom: -45px;
  43.             display: block;
  44.             width: 100%;
  45.             padding: 0;
  46.             list-style: none;
  47.             text-align: center;
  48.         }
  49.         .slick-dots li {
  50.             position: relative;
  51.             display: inline-block;
  52.             width: 20px;
  53.             height: 20px;
  54.             margin: 0 5px;
  55.             padding: 0;
  56.             cursor: pointer;
  57.         }
  58.         .slick-dots li button {
  59.             font-size: 0;
  60.             line-height: 0;
  61.             display: block;
  62.             width: 20px;
  63.             height: 20px;
  64.             padding: 5px;
  65.             cursor: pointer;
  66.             color: transparent;
  67.             border: 0;
  68.             outline: none;
  69.             background: transparent;
  70.         }
  71.         .slick-dots li button:hover,
  72.         .slick-dots li button:focus {
  73.             outline: none;
  74.         }
  75.         .slick-dots li button:hover:before,
  76.         .slick-dots li button:focus:before {
  77.             opacity: 1;
  78.         }
  79.         .slick-dots li button:before {
  80.             content: " ";
  81.             line-height: 20px;
  82.             position: absolute;
  83.             top: 0;
  84.             left: 0;
  85.             width: 12px;
  86.             height: 12px;
  87.             text-align: center;
  88.             opacity: .25;
  89.             background-color: black;
  90.             border-radius: 50%;
  91.         }
  92.         .slick-dots li.slick-active button:before {
  93.             opacity: .75;
  94.             background-color: black;
  95.         }
  96.         .slick-dots li button.thumbnail img {
  97.             width: 0;
  98.             height: 0;
  99.         }
  100.     </style>
  101. {% endblock %}
  102. {% block javascript %}
  103.     <script>
  104.         $(function () {
  105.             eccube.productsClassCategories = {
  106.                 {% for Product in Products_new %}
  107.                     "{{ Product.id|escape('js') }}": {{ class_categories_as_json(Product)|raw }}{% if not loop.last or Products_semi is not empty %}, {% endif %}
  108.                 {% endfor %}
  109.                 {% for Product in Products_semi %}
  110.                     "{{ Product.id|escape('js') }}": {{ class_categories_as_json(Product)|raw }}{% if not loop.last %}, {% endif %}
  111.                 {% endfor %}
  112.             };
  113.             eccube.common.initProductDetail($('.add-cart').closest('form'));
  114.         });
  115.         $(function() {
  116.             // お気に入り追加
  117.             $('.add_favorite').on('click', function(e) {
  118.                 var data = $(this).data();
  119.                 if (confirm(data.product_name + '\r\n\r\n' + 'こちらの商品をお気に入りに登録しますか?') ) {
  120.                 } else {
  121.                     return false;
  122.                 }
  123.             });
  124.             
  125.            $('.add-cart').on('click', function(e) {
  126.                 var data = $(this).data();
  127.                 var $form = $('#productForm' + data.cartid);
  128.                 
  129.                 e.preventDefault();
  130.                 var formData = new FormData($form[0]);
  131.                 // ✅ `ProductClass` の値を確実にセット
  132.                 let productClassValue = $form.find('input[name="ProductClass"]').val();
  133.                 if (!productClassValue) {
  134.                     alert("商品規格が選択されていません");
  135.                     return;
  136.                 }
  137.                 formData.append('ProductClass', productClassValue);
  138.                 $.ajax({
  139.                     url: $form.attr('action'),
  140.                     type: $form.attr('method'),
  141.                     data: $form.serialize(),
  142.                     dataType: 'json',
  143.                     beforeSend: function(xhr, settings) {
  144.                         // Buttonを無効にする
  145.                         $('.add-cart').prop('disabled', true);
  146.                     }
  147.                 }).done(function(data) {
  148.                     // レスポンス内のメッセージをalertで表示
  149.                     $.each(data.messages, function() {
  150.                         $('#ec-modal-header').text(this);
  151.                     });
  152.                     // カートブロックを更新する
  153.                     $.ajax({
  154.                         url: '{{ url('block_cart') }}',
  155.                         type: 'GET',
  156.                         dataType: 'html'
  157.                     }).done(function(html) {
  158.                         const $html = $('<div>').html(html);
  159.                         // ① ヘッダー用のカート部分を更新
  160.                         const $headerCart = $html.find('.ec-headerRole__cart');
  161.                         if ($headerCart.length) {
  162.                             $('.ec-headerRole__cart').replaceWith($headerCart);
  163.                         }
  164.                         // ② サイドカート(ec-cartNaviWrap)も更新
  165.                         const $sideCart = $html.find('.ec-cartNaviWrap');
  166.                         if ($sideCart.length) {
  167.                             $('.ec-cartNaviWrap').replaceWith($sideCart);
  168.                         }
  169.                     });
  170.                     $('.ec-modal').show()
  171.                     
  172.             
  173.                 }).fail(function(xhr, textStatus, errorThrown) {
  174.                     alert('{{ 'カートへの追加に失敗しました。' |trans }}');
  175.                 }).always(function(data) {
  176.                     // Buttonを有効にする
  177.                     $('.add-cart').prop('disabled', false);
  178.                 });
  179.             });
  180.         
  181.         $('.ec-modal-wrap').on('click', function(e) {
  182.             // モーダル内の処理は外側にバブリングさせない
  183.             e.stopPropagation();
  184.         });
  185.         $('.ec-modal-overlay, .ec-modal, .ec-modal-close, .ec-inlineBtn--cancel').on('click', function() {
  186.             $('.ec-modal').hide()
  187.         });
  188.     });
  189.     </script>
  190. {% endblock javascript %}
  191. {% block main %}
  192. {% endblock %}