app/template/BlackCherry/Product/detail.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 = 'product_page' %}
  10. {% block stylesheet %}
  11.     <style>
  12.         .slick-slider {
  13.             margin-bottom: 30px;
  14.         }
  15.         .slick-dots {
  16.             position: absolute;
  17.             bottom: -45px;
  18.             display: block;
  19.             width: 100%;
  20.             padding: 0;
  21.             list-style: none;
  22.             text-align: center;
  23.         }
  24.         .slick-dots li {
  25.             position: relative;
  26.             display: inline-block;
  27.             width: 20px;
  28.             height: 20px;
  29.             margin: 0 5px;
  30.             padding: 0;
  31.             cursor: pointer;
  32.         }
  33.         .slick-dots li button {
  34.             font-size: 0;
  35.             line-height: 0;
  36.             display: block;
  37.             width: 20px;
  38.             height: 20px;
  39.             padding: 5px;
  40.             cursor: pointer;
  41.             color: transparent;
  42.             border: 0;
  43.             outline: none;
  44.             background: transparent;
  45.         }
  46.         .slick-dots li button:hover,
  47.         .slick-dots li button:focus {
  48.             outline: none;
  49.         }
  50.         .slick-dots li button:hover:before,
  51.         .slick-dots li button:focus:before {
  52.             opacity: 1;
  53.         }
  54.         .slick-dots li button:before {
  55.             content: " ";
  56.             line-height: 20px;
  57.             position: absolute;
  58.             top: 0;
  59.             left: 0;
  60.             width: 12px;
  61.             height: 12px;
  62.             text-align: center;
  63.             opacity: .25;
  64.             background-color: black;
  65.             border-radius: 50%;
  66.         }
  67.         .slick-dots li.slick-active button:before {
  68.             opacity: .75;
  69.             background-color: black;
  70.         }
  71.         .slick-dots li button.thumbnail img {
  72.             width: 0;
  73.             height: 0;
  74.         }
  75.     </style>
  76. {% endblock %}
  77. {% block javascript %}
  78.     <script>
  79.         eccube.classCategories = {{ class_categories_as_json(Product)|raw }};
  80.         // 規格2に選択肢を割り当てる。
  81.         function fnSetClassCategories(form, classcat_id2_selected) {
  82.             var $form = $(form);
  83.             var product_id = $form.find('input[name=product_id]').val();
  84.             var $sele1 = $form.find('select[name=classcategory_id1]');
  85.             var $sele2 = $form.find('select[name=classcategory_id2]');
  86.             eccube.setClassCategories($form, product_id, $sele1, $sele2, classcat_id2_selected);
  87.         }
  88.         {% if form.classcategory_id2 is defined %}
  89.         fnSetClassCategories(
  90.             $('#form1'), {{ form.classcategory_id2.vars.value|json_encode|raw }}
  91.         );
  92.         {% elseif form.classcategory_id1 is defined %}
  93.         eccube.checkStock($('#form1'), {{ Product.id }}, {{ form.classcategory_id1.vars.value|json_encode|raw }}, null);
  94.         {% endif %}
  95.     </script>
  96.     <script>
  97.         $(function() {
  98.             // bfcache無効化
  99.             $(window).bind('pageshow', function(event) {
  100.                 if (event.originalEvent.persisted) {
  101.                     location.reload(true);
  102.                 }
  103.             });
  104.             // Core Web Vital の Cumulative Layout Shift(CLS)対策のため
  105.             // img タグに width, height が付与されている.
  106.             // 630px 未満の画面サイズでは縦横比が壊れるための対策
  107.             // see https://github.com/EC-CUBE/ec-cube/pull/5023
  108.             $('.ec-grid2__cell').hide();
  109.             var removeSize = function () {
  110.                 $('.slide-item').height('');
  111.                 $('.slide-item img')
  112.                     .removeAttr('width')
  113.                     .removeAttr('height')
  114.                     .removeAttr('style');
  115.             };
  116.             var slickInitial = function(slick) {
  117.                 $('.ec-grid2__cell').fadeIn(1500);
  118.                 var baseHeight = $(slick.target).height();
  119.                 var baseWidth = $(slick.target).width();
  120.                 var rate = baseWidth / baseHeight;
  121.                 $('.slide-item').height(baseHeight * rate); // 余白を削除する
  122.                 // transform を使用することでCLSの影響を受けないようにする
  123.                 $('.slide-item img')
  124.                     .css(
  125.                         {
  126.                             'transform-origin': 'top left',
  127.                             'transform': 'scaleY(' + rate + ')',
  128.                             'transition': 'transform .1s'
  129.                         }
  130.                     );
  131.                 // 正しいサイズに近くなったら属性を解除する
  132.                 setTimeout(removeSize, 500);
  133.             };
  134.             $('.item_visual').on('init', slickInitial);
  135.             // リサイズ時は CLS の影響を受けないため属性を解除する
  136.             $(window).resize(removeSize);
  137.             $('.item_visual').slick({
  138.                 dots: false,
  139.                 arrows: false,
  140.                 responsive: [{
  141.                     breakpoint: 768,
  142.                     settings: {
  143.                         dots: true
  144.                     }
  145.                 }]
  146.             });
  147.             $('.slideThumb').on('click', function() {
  148.                 var index = $(this).attr('data-index');
  149.                 $('.item_visual').slick('slickGoTo', index, false);
  150.             })
  151.         });
  152.     </script>
  153.     <script>
  154.         $(function() {
  155.             // お気に入り追加
  156.             $('.add_favorite').on('click', function(e) {
  157.                 var data = $(this).data();
  158.                 if (confirm(data.product_name + '\r\n\r\n' + 'こちらの商品をお気に入りに登録しますか?') ) {
  159.                 } else {
  160.                     return false;
  161.                 }
  162.             });
  163.             // カート追加
  164.             $('.add-cart').on('click', function(event) {
  165.                 
  166.                 {% if form.classcategory_id1 is defined %}
  167.                 // 規格1フォームの必須チェック
  168.                 if ($('#classcategory_id1').val() == '__unselected' || $('#classcategory_id1').val() == '') {
  169.                     $('#classcategory_id1')[0].setCustomValidity('{{ '項目が選択されていません'|trans }}');
  170.                     return true;
  171.                 } else {
  172.                     $('#classcategory_id1')[0].setCustomValidity('');
  173.                 }
  174.                 {% endif %}
  175.                 {% if form.classcategory_id2 is defined %}
  176.                 // 規格2フォームの必須チェック
  177.                 if ($('#classcategory_id2').val() == '__unselected' || $('#classcategory_id2').val() == '') {
  178.                     $('#classcategory_id2')[0].setCustomValidity('{{ '項目が選択されていません'|trans }}');
  179.                     return true;
  180.                 } else {
  181.                     $('#classcategory_id2')[0].setCustomValidity('');
  182.                 }
  183.                 {% endif %}
  184.                 // 個数フォームのチェック
  185.                 if ($('#quantity').val() < 1) {
  186.                     $('#quantity')[0].setCustomValidity('{{ '1以上で入力してください。'|trans }}');
  187.                     return true;
  188.                 } else {
  189.                     $('#quantity')[0].setCustomValidity('');
  190.                 }
  191.                 event.preventDefault();
  192.                 $form = $('#form1');
  193.                 $.ajax({
  194.                     url: $form.attr('action'),
  195.                     type: $form.attr('method'),
  196.                     data: $form.serialize(),
  197.                     dataType: 'json',
  198.                     beforeSend: function(xhr, settings) {
  199.                         // Buttonを無効にする
  200.                         $('.add-cart').prop('disabled', true);
  201.                     }
  202.                 }).done(function(data) {
  203.                     // レスポンス内のメッセージをalertで表示
  204.                     $.each(data.messages, function() {
  205.                         $('#ec-modal-header').text(this);
  206.                     });
  207.                     $('.ec-modal').show()
  208.                     // カートブロックを更新する
  209.                     $.ajax({
  210.                         url: "{{ url('block_cart') }}",
  211.                         type: 'GET',
  212.                         dataType: 'html'
  213.                     }).done(function(html) {
  214.                         const $html = $('<div>').html(html);
  215.                         // ① ヘッダー用のカート部分を更新
  216.                         const $headerCart = $html.find('.ec-headerRole__cart');
  217.                         if ($headerCart.length) {
  218.                             $('.ec-headerRole__cart').replaceWith($headerCart);
  219.                         }
  220.                         // ② サイドカート(ec-cartNaviWrap)も更新
  221.                         const $sideCart = $html.find('.ec-cartNaviWrap');
  222.                         if ($sideCart.length) {
  223.                             $('.ec-cartNaviWrap').replaceWith($sideCart);
  224.                         }
  225.                     });
  226.                     
  227.                 }).fail(function(data) {
  228.                     alert('{{ 'カートへの追加に失敗しました。'|trans }}');
  229.                 }).always(function(data) {
  230.                     // Buttonを有効にする
  231.                     $('.add-cart').prop('disabled', false);
  232.                 });
  233.             });
  234.         });
  235.         $('.ec-modal-wrap').on('click', function(e) {
  236.             // モーダル内の処理は外側にバブリングさせない
  237.             e.stopPropagation();
  238.         });
  239.         $('.ec-modal-overlay, .ec-modal, .ec-modal-close, .ec-inlineBtn--cancel').on('click', function() {
  240.             $('.ec-modal').hide()
  241.         });
  242.     </script>
  243.     <script type="application/ld+json">
  244.     {
  245.         "@context": "https://schema.org/",
  246.         "@type": "Product",
  247.         "name": "{{ Product.name }}",
  248.         "image": [
  249.             {% for img in Product.ProductImage %}
  250.                 "{{ app.request.schemeAndHttpHost }}{{ asset(img, 'save_image') }}"{% if not loop.last %},{% endif %}
  251.             {% else %}
  252.                 "{{ app.request.schemeAndHttpHost }}{{ asset(''|no_image_product, 'save_image') }}"
  253.             {% endfor %}
  254.         ],
  255.         "description": "{{ Product.description_list | default(Product.description_detail) | replace({'\n': '', '\r': ''}) | slice(0,300) }}",
  256.         {% if Product.code_min %}
  257.         "sku": "{{ Product.code_min }}",
  258.         {% endif %}
  259.         "offers": {
  260.             "@type": "Offer",
  261.             "url": "{{ url('product_detail', {'id': Product.id}) }}",
  262.             "priceCurrency": "{{ eccube_config.currency }}",
  263.             "price": {{ Product.getPrice02IncTaxMin ? Product.getPrice02IncTaxMin : 0}},
  264.             "availability": "{{ Product.stock_find ? "InStock" : "OutOfStock" }}"
  265.         }
  266.     }
  267.     </script>
  268. {% endblock %}
  269. {% block main %}
  270.     <div class="ec-productRole">
  271.         <div class="ec-grid2">
  272.             <div class="ec-grid2__cell">
  273.                 <div class="ec-sliderItemRole">
  274.                     <!--▼商品画像▼-->
  275.                     <div class="item_visual">
  276.                         {% for ProductImage in Product.ProductImage %}
  277.                             <div class="slide-item"><img src="{{ asset(ProductImage, 'save_image') }}" alt="{{ loop.first ? Product.name : '' }}" {% if loop.index > 1 %} loading="lazy"{% endif %}></div>
  278.                         {% else %}
  279.                             <div class="slide-item"><img src="{{ asset(''|no_image_product, 'save_image') }}" alt="{{ loop.first ? Product.name : '' }}" width="550" height="550"></div>
  280.                         {% endfor %}
  281.                     </div>
  282.                     <!--▲商品画像▲-->
  283.                     <!--
  284.                     <div class="item_nav">
  285.                         {% for ProductImage in Product.ProductImage %}
  286.                             <div class="slideThumb" data-index="{{ loop.index0 }}"><img src="{{ asset(ProductImage, 'save_image') }}" alt="" width="133" height="133" loading="lazy"></div>
  287.                         {% endfor %}
  288.                     </div>
  289.                     -->
  290.                 </div>
  291.             </div>
  292.             <!--▼商品紹介テーブル▼-->
  293.             <div class="ec-grid2__cell">
  294.               <table class="detail-table">
  295.                 <!--★商品名★-->
  296.                 <tr class="detail-table__title">
  297.                   <th>商品名</th>
  298.                   <td>
  299.                     <p>{{ Product.name }}</p>
  300.                   </td>
  301.                 </tr>
  302.                 <!--★キャスト★-->
  303.                 <tr class="detail-table__item">
  304.                   <th>出演女優</th>
  305.                     {% if Product.actress is not empty %}
  306.                         <td>
  307.                             {% set actresses = Product.actress|split(',') %}
  308.                             {% for actress in actresses %}
  309.                                 {% set actress = actress|trim %}
  310.                                 <a href="{{ url('product_list') }}?date=&maker_id=&keyword={{ actress|url_encode }}">{{ actress }}</a>{% if not loop.last %}, {% endif %}
  311.                             {% endfor %}
  312.                         </td>
  313.                     {% endif %}
  314.                   
  315.                 </tr>
  316.                 <!--★発売日★-->
  317.                 <tr class="detail-table__item">
  318.                   <th>入荷日</th>
  319.                   <td>
  320.                     {% for productCategory in Product.ProductCategories %}
  321.                         {% set parent_category = productCategory.Category %}
  322.                         {% if parent_category is not empty %}
  323.                             {% set category_name = parent_category.name %}
  324.                             {# 8桁なら YY年MM月DD日 に変換 #}
  325.                             <a href="{{ url('product_list') }}?date={{ category_name[:4] ~ '-' ~ category_name[4:2] ~ '-' ~ category_name[6:2] }}&maker_id=&keyword=">
  326.                                 {{ category_name[:4] ~ '年' ~ category_name[4:2] ~ '月' ~ category_name[6:2] ~ '日' }}
  327.                             </a>
  328.                         {% endif %}
  329.                     {% endfor %}
  330.                   </td>
  331.                 </tr>
  332.                 <!--★収録時間★-->
  333.                 <tr class="detail-table__item">
  334.                   <th>収録時間</th>
  335.                   <td>{{ Product.recording_time }}</td>
  336.                 </tr>
  337.                 <!--★メーカー★-->
  338.                 {% if Product.Maker is not empty %}
  339.                 <tr class="detail-table__item">
  340.                     <th>メーカー</th>
  341.                     <td>
  342.                         <a href="{{ url('product_list') }}?date=&maker_id={{ Product.Maker.id }}&keyword=">{{ Product.Maker.name }}</a>
  343.                     </td>
  344.                 </tr>
  345.                 {% endif %}
  346.                 <!--★詳細メインコメント★-->
  347.                 <tr class="detail-table__desc">
  348.                   <th>商品コメント</th>
  349.                   <td>
  350.                     <p>{{ Product.description_detail|raw|nl2br }}</p>
  351.                     <br>
  352.                     <p>※当作品の出演者は全て18歳以上です。</p>
  353.                   </td>
  354.                 </tr>
  355.               </table>
  356.               <!--▲商品紹介テーブル▲-->
  357.               <br>
  358.               <!--▼買い物かごエリア▼-->
  359.               <form action="{{ url('product_add_cart', {id:Product.id}) }}" method="post" id="form1" name="form1">
  360.                 <table class="detail-class">
  361.                   <tr class="detail-class_plan">
  362.                     {% if form.classcategory_id1 is defined %}
  363.                       <th>{{ form_label(form.classcategory_id1) }}</th>
  364.                       <td>
  365.                         <div class="ec-select">
  366.                           {{ form_widget(form.classcategory_id1 ) }}
  367.                           {{ form_errors(form.classcategory_id1) }}
  368.                         </div>
  369.                       </td>
  370.                       {% if form.classcategory_id2 is defined %}
  371.                         <th>{{ form_label(form.classcategory_id2) }}</th>
  372.                         <td>
  373.                           <div class="ec-select">
  374.                             {{ form_row(form.classcategory_id2) }}
  375.                             {{ form_errors(form.classcategory_id2) }}
  376.                           </div>
  377.                         </td>
  378.                       {% endif %}
  379.                     {% endif %}
  380.                   </tr>
  381.                   <tr class="detail-class_price">
  382.                     <th>価格(税込)</th>
  383.                     <td>
  384.                       <div class="ec-productRole__price">
  385.                                 <div class="ec-price">
  386.                                     <span class="ec-price__price price02-default">{{ Product.getPrice02IncTaxMin|price }}</span>
  387.                                     <span class="ec-price__tax">{{ '円'|trans }}</span>
  388.                                 </div>
  389.                       </div>
  390.                     </td>
  391.                   </tr>
  392.                 </table>
  393.                 <div class="ec-numberInput">
  394.                   {{ form_widget(form.quantity, { data: '1', type: 'hidden'} ) }}
  395.                 </div>
  396.                 {{ form_rest(form) }}
  397.                 </form>
  398.                 
  399.                 
  400.                <!-- Button -->
  401.                <div class="cart-btn">
  402.                  {% if BaseInfo.option_favorite_product %}
  403.                    <form action="{{ url('product_add_favorite', {id:Product.id}) }}" method="post">
  404.                      <div class="ec-productRole__btn">
  405.                       {% if favorite == false %}
  406.                         <input type="image" id="favorite" class="ec-blockBtn--cancel add_favorite" src="{{ asset('assets/img/new/img_favorite-add.png') }}" alt="お気に入りに追加" data-product_name="{{ Product.name}}" />
  407.                       {% else %}
  408.                         <input type="image" class="ec-blockBtn--cancel" disabled="disabled" src="{{ asset('assets/img/new/img_favorite-added.png') }}" alt="お気に入りに追加済" />
  409.                       {% endif %}
  410.                      </div>
  411.                    </form>
  412.                  {% endif %}
  413.                 <div class="ec-productRole__btn">
  414.                   <input type="image" src="{{ asset('assets/img/new/img_cart-add.png') }}" alt="カートに入れる" class="ec-blockBtn--action add-cart" data-cartid="{{ Product.id }}" form="productForm{{ Product.id }}" />
  415.                 </div>
  416.              </div>
  417.              
  418.              <!-- モーダルウィンドウ -->
  419.              <div class="ec-modal">
  420.                 <div class="ec-modal-overlay">
  421.                   <div class="ec-modal-wrap">
  422.                     <span class="ec-modal-close"><span class="ec-icon"><img src="{{ asset('assets/icon/cross-dark.svg') }}" alt=""/></span></span>
  423.                     <div id="ec-modal-header" class="text-center">{{ 'カートに追加しました。'|trans }}</div>
  424.                       <div class="ec-modal-box">
  425.                         <div class="ec-role">
  426.                           <span class="ec-inlineBtn--cancel">{{ 'お買い物を続ける'|trans }}</span>
  427.                           <a href="{{ url('cart') }}" class="ec-inlineBtn--action">{{ 'カートへ進む'|trans }}</a>
  428.                         </div>
  429.                       </div>
  430.                     </div>
  431.                   </div>
  432.                 </div>
  433.              </div>
  434.         </div>
  435.     </div>
  436. {% endblock %}