app/template/kaorime/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.             $('.add-cart').on('click', function(event) {
  156.                 {% if form.classcategory_id1 is defined %}
  157.                 // 規格1フォームの必須チェック
  158.                 if ($('#classcategory_id1').val() == '__unselected' || $('#classcategory_id1').val() == '') {
  159.                     $('#classcategory_id1')[0].setCustomValidity('{{ '項目が選択されていません'|trans }}');
  160.                     return true;
  161.                 } else {
  162.                     $('#classcategory_id1')[0].setCustomValidity('');
  163.                 }
  164.                 {% endif %}
  165.                 {% if form.classcategory_id2 is defined %}
  166.                 // 規格2フォームの必須チェック
  167.                 if ($('#classcategory_id2').val() == '__unselected' || $('#classcategory_id2').val() == '') {
  168.                     $('#classcategory_id2')[0].setCustomValidity('{{ '項目が選択されていません'|trans }}');
  169.                     return true;
  170.                 } else {
  171.                     $('#classcategory_id2')[0].setCustomValidity('');
  172.                 }
  173.                 {% endif %}
  174.                 // 個数フォームのチェック
  175.                 if ($('#quantity').val() < 1) {
  176.                     $('#quantity')[0].setCustomValidity('{{ '1以上で入力してください。'|trans }}');
  177.                     return true;
  178.                 } else {
  179.                     $('#quantity')[0].setCustomValidity('');
  180.                 }
  181.                 event.preventDefault();
  182.                 $form = $('#form1');
  183.                 $.ajax({
  184.                     url: $form.attr('action'),
  185.                     type: $form.attr('method'),
  186.                     data: $form.serialize(),
  187.                     dataType: 'json',
  188.                     beforeSend: function(xhr, settings) {
  189.                         // Buttonを無効にする
  190.                         $('.add-cart').prop('disabled', true);
  191.                     }
  192.                 }).done(function(data) {
  193.                     // レスポンス内のメッセージをalertで表示
  194.                     $.each(data.messages, function() {
  195.                         $('#ec-modal-header').text(this);
  196.                     });
  197.                     $('.ec-modal').show()
  198.                     // カートブロックを更新する
  199.                     $.ajax({
  200.                         url: "{{ url('block_cart') }}",
  201.                         type: 'GET',
  202.                         dataType: 'html'
  203.                     }).done(function(html) {
  204.                         $('.ec-headerRole__cart').html(html);
  205.                     });
  206.                 }).fail(function(data) {
  207.                     alert('{{ 'カートへの追加に失敗しました。'|trans }}');
  208.                 }).always(function(data) {
  209.                     // Buttonを有効にする
  210.                     $('.add-cart').prop('disabled', false);
  211.                 });
  212.             });
  213.         });
  214.         $('.ec-modal-wrap').on('click', function(e) {
  215.             // モーダル内の処理は外側にバブリングさせない
  216.             e.stopPropagation();
  217.         });
  218.         $('.ec-modal-overlay, .ec-modal, .ec-modal-close, .ec-inlineBtn--cancel').on('click', function() {
  219.             $('.ec-modal').hide()
  220.         });
  221.     </script>
  222.     <script type="application/ld+json">
  223.     {
  224.         "@context": "https://schema.org/",
  225.         "@type": "Product",
  226.         "name": "{{ Product.name }}",
  227.         "image": [
  228.             {% for img in Product.ProductImage %}
  229.                 "{{ app.request.schemeAndHttpHost }}{{ asset(img, 'save_image') }}"{% if not loop.last %},{% endif %}
  230.             {% else %}
  231.                 "{{ app.request.schemeAndHttpHost }}{{ asset(''|no_image_product, 'save_image') }}"
  232.             {% endfor %}
  233.         ],
  234.         "description": "{{ Product.description_list | default(Product.description_detail) | replace({'\n': '', '\r': ''}) | slice(0,300) }}",
  235.         {% if Product.code_min %}
  236.         "sku": "{{ Product.code_min }}",
  237.         {% endif %}
  238.         "offers": {
  239.             "@type": "Offer",
  240.             "url": "{{ url('product_detail', {'id': Product.id}) }}",
  241.             "priceCurrency": "{{ eccube_config.currency }}",
  242.             "price": {{ Product.getPrice02IncTaxMin ? Product.getPrice02IncTaxMin : 0}},
  243.             "availability": "{{ Product.stock_find ? "InStock" : "OutOfStock" }}"
  244.         }
  245.     }
  246.     </script>
  247. {% endblock %}
  248. {% block main %}
  249.     <!-- PAGE CONTENTS -->
  250.     <div class="products productsWakamefurikake productsSingle">
  251.         <section class="sub-container">
  252.             <!-- H1 商品カテゴリーの見出し -->
  253.             <div class="sub-h1--products">
  254.                 <h1 class="itemTitle" style="color: #221613;">
  255.                     {{ Product.name }}
  256.                 </h1>
  257.                 <div class="itemImg">
  258.                     <div class="itemImgInner">
  259.                         <img src="{{ asset('assets/img/products/sub_h1_02.jpg') }}" alt="" class="imgObjectFitCover">
  260.                     </div>
  261.                 </div>
  262.             </div>
  263.             <!-- /H1 -->
  264.             <!-- CONTENTS -->
  265.             <div class="l-container l-2ColumnContainer">
  266.                 <!-- MAIN-CONTENTS -->
  267.                 <div class="l-main">
  268.                     <!-- BREAD CRUMBS -->
  269.                     <div class="sub-breadcrumbsWrap">
  270.                         <ul class="sub-breadcrumbs">
  271.                             <li><a href="/">TOP</a></li>
  272.                             <li><a href="/products/list">商品一覧</a></li>
  273.                             <li>{{ Product.name }}</li>
  274.                         </ul>
  275.                     </div>
  276.                     <!-- /BREAD CRUMBS -->
  277.                     <!-- MAIN CONTENTS -->
  278.                     <section class="products-sgContent">
  279.                         <!-- PRODUCTS PHOTO -->
  280.                         <div class="products-sgContent__pPhoto">
  281.                             <div class="productsPhotoSlide">
  282.                                 <ul id="categorySingleSlider" class="main clearfix">
  283.                                     {% for ProductImage in Product.ProductImage %}
  284.                                         <li><span class="imgWrap">
  285.                                                 <img src="{{ asset(ProductImage, 'save_image') }}" alt="{{ loop.first ? Product.name : '' }}" alt=""
  286.                                                                        class="imgObjectFitCover" {% if loop.index > 1 %} loading="lazy"{% endif %}>
  287.                                             </span>
  288.                                         </li>
  289.                                     {% else %}
  290.                                         <li>
  291.                                             <span class="imgWrap">
  292.                                                 <img src="{{ asset(''|no_image_product, 'save_image') }}" alt="{{ loop.first ? Product.name : '' }}"
  293.                                                                        class="imgObjectFitCover">
  294.                                             </span>
  295.                                         </li>
  296.                                     {% endfor %}
  297.                                 </ul>
  298.                                 <ul id="categorySingleSliderNav" class="sub clearfix">
  299.                                     {% for ProductImage in Product.ProductImage %}
  300.                                         <li data-index="{{ loop.index0 }}">
  301.                                             <span class="imgWrap">
  302.                                                 <img src="{{ asset(ProductImage, 'save_image') }}" alt=""
  303.                                                      class="imgObjectFitCover" loading="lazy">
  304.                                             </span>
  305.                                         </li>
  306.                                     {% endfor %}
  307.                                 </ul>
  308.                             </div>
  309.                         </div>
  310.                         <!-- /PRODUCTS PHOTO -->
  311.                         <!-- PRODUCTS DATA -->
  312.                         <div class="products-sgContent__pData">
  313.                             <div class="titleWrap">
  314.                                 <h2 class="itemPName">{{ Product.name }}</h2>
  315.                                 {# 販売価格 #}
  316.                                 <p class="itemPrice" style="margin-top:20px;">
  317.                                     {% if Product.getPrice01Min is not null %}
  318.                                         {% set priceClass = "color: #f00;font-weight: bold;font-size: 27px;text-align:right;" %}
  319.                                     {% else %}
  320.                                         {% set priceClass = "font-weight: bold;font-size: 27px;text-align:right;" %}
  321.                                     {% endif %}
  322.                                 <div style="{{ priceClass }}">
  323.                                     {% if Product.hasProductClass %}
  324.                                         {% if Product.getPrice02Min == Product.getPrice02Max %}
  325.                                             {{ Product.getPrice02IncTaxMin|number_format }}
  326.                                         {% else %}
  327.                                             {{ Product.getPrice02IncTaxMin|number_format }}
  328.                                             ~
  329.                                             {{ Product.getPrice02IncTaxMax|number_format }}
  330.                                         {% endif %}
  331.                                         円
  332.                                         <small class="isSmall" style="font-size: 15px;">(税込)</small>
  333.                                     {% else %}
  334.                                         {{ Product.getPrice02IncTaxMin|number_format }}
  335.                                         円
  336.                                         <small class="isSmall" style="font-size: 15px;">(税込)</small>
  337.                                     {% endif %}
  338.                                 </div>
  339.                                 <div class="font13 textRight" style="margin-top:10px;text-decoration: line-through;color:#666;">
  340.                                     {% if Product.hasProductClass %}
  341.                                         <div>
  342.                                             {% if Product.getPrice01Min is not null and Product.getPrice01IncTaxMin == Product.getPrice01IncTaxMax %}
  343.                                                 {{ Product.getPrice01IncTaxMin|number_format }}円
  344.                                                 <span class="tax">(税込)</span>
  345.                                             {% elseif Product.getPrice01Min is not null and Product.getPrice01Max is not null %}
  346.                                                 {{ Product.getPrice01IncTaxMin|number_format }}~ {{ Product.getPrice01IncTaxMax|number_format }}円
  347.                                                 <span class="tax">(税込)</span>
  348.                                             {% endif %}
  349.                                         </div>
  350.                                     {% else %}
  351.                                         {% if Product.getPrice01Max is not null %}
  352.                                             {{ Product.getPrice01IncTaxMin|number_format }}円
  353.                                             <span class="tax">(税込)</span>
  354.                                         {% endif %}
  355.                                     {% endif %}
  356.                                 </div>
  357.                                 </p>
  358.                                 {#
  359.                                 {% if Product.hasProductClass -%}
  360.                                     {% if Product.getPrice02IncTaxMin == Product.getPrice02IncTaxMax %}
  361.                                         <p class="itemPrice">
  362.                                             {{ Product.getPrice02IncTaxMin|price }}
  363.                                             <span class="tax">{{ '(税込)'|trans }}</span>
  364.                                         </p>
  365.                                     {% else %}
  366.                                         <p class="itemPrice">
  367.                                             {{ Product.getPrice02IncTaxMin|price }} ~ {{ Product.getPrice02IncTaxMax|price }}
  368.                                             <span class="tax">{{ '(税込)'|trans }}</span>
  369.                                         </p>
  370.                                     {% endif %}
  371.                                 {% else %}
  372.                                         <p class="itemPrice">
  373.                                             {{ Product.getPrice02IncTaxMin|price }}
  374.                                             <span class="tax">{{ '(税込)'|trans }}</span>
  375.                                         </p>
  376.                                 {% endif %}
  377.                                 #}
  378.                             </div>
  379.                             <form action="{{ url('product_add_cart', {id:Product.id}) }}" method="post" id="form1" name="form1">
  380.                                 {% if Product.stock_find %}
  381.                                     <div class="ec-productRole__actions">
  382.                                         {% if form.classcategory_id1 is defined %}
  383.                                             <div class="ec-select">
  384.                                                 {{ form_row(form.classcategory_id1) }}
  385.                                                 {{ form_errors(form.classcategory_id1) }}
  386.                                             </div>
  387.                                             {% if form.classcategory_id2 is defined %}
  388.                                                 <div class="ec-select">
  389.                                                     {{ form_row(form.classcategory_id2) }}
  390.                                                     {{ form_errors(form.classcategory_id2) }}
  391.                                                 </div>
  392.                                             {% endif %}
  393.                                         {% endif %}
  394.                                         <div class="quantityWrap">
  395.                                             <span>数量</span>
  396.                                             <div class="quantityWrapInner">
  397.                                                 <div class="item-select">
  398.                                                     {{ form_widget(form.quantity) }}
  399.                                                     {{ form_errors(form.quantity) }}
  400.                                                 </div>
  401.                                                 <div class="product-single-quantityBtnBlock">
  402.                                                     <div class="quantityBtn quantityBtn__plus"><span class="btnInner">+</span></div>
  403.                                                     <div class="quantityBtn quantityBtn__minus"><span class="btnInner">-</span></div>
  404.                                                 </div>
  405.                                             </div>
  406.                                         </div>
  407.                                     </div>
  408.                                     <div class="cartBtnWrap">
  409.                                         <button type="submit" class="ec-blockBtn--action add-cart mod-btn-02 cartBtn">
  410.                                             {{ 'カートに入れる'|trans }}
  411.                                         </button>
  412.                                     </div>
  413.                                 {% else %}
  414.                                     <div class="ec-productRole__btn">
  415.                                         <button type="button" class="ec-blockBtn--action" disabled="disabled">
  416.                                             {{ 'ただいま品切れ中です。'|trans }}
  417.                                         </button>
  418.                                     </div>
  419.                                 {% endif %}
  420.                                 <div class="ec-modal">
  421.                                     <div class="ec-modal-overlay">
  422.                                         <div class="ec-modal-wrap">
  423.                                             <span class="ec-modal-close"><span class="ec-icon"><img src="{{ asset('assets/icon/cross-dark.svg') }}" alt=""/></span></span>
  424.                                             <div id="ec-modal-header" class="text-center">{{ 'カートに追加しました。'|trans }}</div>
  425.                                             <div class="ec-modal-box">
  426.                                                 <div class="ec-role">
  427.                                                     <span class="ec-inlineBtn--cancel">{{ 'お買い物を続ける'|trans }}</span>
  428.                                                     <a href="{{ url('cart') }}" class="ec-inlineBtn--action">{{ 'カートへ進む'|trans }}</a>
  429.                                                 </div>
  430.                                             </div>
  431.                                         </div>
  432.                                     </div>
  433.                                 </div>
  434.                                 {{ form_rest(form) }}
  435.                             </form>
  436.                             {% if BaseInfo.option_favorite_product %}
  437.                                 <form action="{{ url('product_add_favorite', {id:Product.id}) }}" method="post">
  438.                                     <div class="favoriteBtnWrap">
  439.                                     {% if is_favorite == false %}
  440.                                         <button type="submit" id="favorite" class="ec-blockBtn--cancel mod-btn-02 favoriteBtn">お気に入りに追加</button>
  441.                                     {% else %}
  442.                                         <button type="submit" id="favorite" class="ec-blockBtn--cancel mod-btn-02 favoriteBtn"
  443.                                                 disabled="disabled">{{ 'お気に入りに追加済です。'|trans }}
  444.                                         </button>
  445.                                     {% endif %}
  446.                                     </div>
  447.                                 </form>
  448.                             {% endif %}
  449.                             <div class="itemInfoWrap">
  450.                                 <p>
  451.                                     {{ Product.description_detail|raw|nl2br }}
  452.                                 </p>
  453.                             </div>
  454.                             {% if Product.freearea %}
  455.                                 <div class="ec-productRole__description">
  456.                                     {{ include(template_from_string(Product.freearea), sandboxed = true) }}
  457.                                 </div>
  458.                             {% endif %}
  459.                         </div>
  460.                         <!-- /PRODUCTS DATA -->
  461.                     </section>
  462.                     <!-- /MAIN CONTENTS -->
  463.                     <div class="marginTop30">
  464.                     {% if plugin_snippets is defined %}
  465.                         {{ include('snippet.twig', { snippets: plugin_snippets }) }}
  466.                     {% endif %}
  467.                     </div>
  468.                     {% if Layout.MainBottom %}
  469.                         {{ include('block.twig', {'Blocks': Layout.MainBottom}) }}
  470.                     {% endif %}
  471.                     {% if Layout.ContentsBottom %}
  472.                         <div class="ec-layoutRole__contentBottom">
  473.                             {{ include('block.twig', {'Blocks': Layout.ContentsBottom}) }}
  474.                         </div>
  475.                     {% endif %}
  476.                 </div>
  477.                 <!-- /MAIN-CONTENTS -->
  478.                 <!-- SIDE-CONTENTS -->
  479.                 {{ include('Block/side_menu.twig') }}
  480.                 <!-- /SIDE-CONTENTS -->
  481.             </div>
  482.             <!-- /CONTENTS -->
  483.         </section>
  484.     </div>
  485.     <!-- /PAGE CONTENTS -->
  486. {% endblock %}