app/template/default/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. <link rel="stylesheet" href="/html/user_data/assets/css/lightbox.min.css">
  12.     <style>
  13.         .slick-slider {
  14.             margin-bottom: 30px;
  15.         }
  16.         .slick-dots {
  17.             position: absolute;
  18.             bottom: -45px;
  19.             display: block;
  20.             width: 100%;
  21.             padding: 0;
  22.             list-style: none;
  23.             text-align: center;
  24.         }
  25.         .slick-dots li {
  26.             position: relative;
  27.             display: inline-block;
  28.             width: 20px;
  29.             height: 20px;
  30.             margin: 0 5px;
  31.             padding: 0;
  32.             cursor: pointer;
  33.         }
  34.         .slick-dots li button {
  35.             font-size: 0;
  36.             line-height: 0;
  37.             display: block;
  38.             width: 20px;
  39.             height: 20px;
  40.             padding: 5px;
  41.             cursor: pointer;
  42.             color: transparent;
  43.             border: 0;
  44.             outline: none;
  45.             background: transparent;
  46.         }
  47.         .slick-dots li button:hover,
  48.         .slick-dots li button:focus {
  49.             outline: none;
  50.         }
  51.         .slick-dots li button:hover:before,
  52.         .slick-dots li button:focus:before {
  53.             opacity: 1;
  54.         }
  55.         .slick-dots li button:before {
  56.             content: " ";
  57.             line-height: 20px;
  58.             position: absolute;
  59.             top: 0;
  60.             left: 0;
  61.             width: 12px;
  62.             height: 12px;
  63.             text-align: center;
  64.             opacity: .25;
  65.             background-color: black;
  66.             border-radius: 50%;
  67.         }
  68.         .slick-dots li.slick-active button:before {
  69.             opacity: .75;
  70.             background-color: black;
  71.         }
  72.         .slick-dots li button.thumbnail img {
  73.             width: 0;
  74.             height: 0;
  75.         }
  76.     </style>
  77. {% endblock %}
  78. {% block javascript %}
  79.     <script src="/html/user_data/assets/js/lightbox.min.js"></script>
  80.     <script>
  81.         eccube.classCategories = {{ class_categories_as_json(Product)|raw }};
  82.         // 規格2に選択肢を割り当てる。
  83.         function fnSetClassCategories(form, classcat_id2_selected) {
  84.             var $form = $(form);
  85.             var product_id = $form.find('input[name=product_id]').val();
  86.             var $sele1 = $form.find('select[name=classcategory_id1]');
  87.             var $sele2 = $form.find('select[name=classcategory_id2]');
  88.             eccube.setClassCategories($form, product_id, $sele1, $sele2, classcat_id2_selected);
  89.         }
  90.         {% if form.classcategory_id2 is defined %}
  91.         fnSetClassCategories(
  92.             $('#form1'), {{ form.classcategory_id2.vars.value|json_encode|raw }}
  93.         );
  94.         {% elseif form.classcategory_id1 is defined %}
  95.         eccube.checkStock($('#form1'), {{ Product.id }}, {{ form.classcategory_id1.vars.value|json_encode|raw }}, null);
  96.         {% endif %}
  97.     </script>
  98.     <script>
  99.         $(function() {
  100.             // bfcache無効化
  101.             $(window).bind('pageshow', function(event) {
  102.                 if (event.originalEvent.persisted) {
  103.                     location.reload(true);
  104.                 }
  105.             });
  106.             // Core Web Vital の Cumulative Layout Shift(CLS)対策のため
  107.             // img タグに width, height が付与されている.
  108.             // 630px 未満の画面サイズでは縦横比が壊れるための対策
  109.             // see https://github.com/EC-CUBE/ec-cube/pull/5023
  110.             $('.ec-grid2__cell').hide();
  111.             var removeSize = function () {
  112.                 $('.slide-item').height('');
  113.                 $('.slide-item img')
  114.                     .removeAttr('width')
  115.                     .removeAttr('height')
  116.                     .removeAttr('style');
  117.             };
  118.             var slickInitial = function(slick) {
  119.                 $('.ec-grid2__cell').fadeIn(1500);
  120.                 var baseHeight = $(slick.target).height();
  121.                 var baseWidth = $(slick.target).width();
  122.                 var rate = baseWidth / baseHeight;
  123.                 $('.slide-item').height(baseHeight * rate); // 余白を削除する
  124.                 // transform を使用することでCLSの影響を受けないようにする
  125.                 $('.slide-item img')
  126.                     .css(
  127.                         {
  128.                             'transform-origin': 'top left',
  129.                             'transform': 'scaleY(' + rate + ')',
  130.                             'transition': 'transform .1s'
  131.                         }
  132.                     );
  133.                 // 正しいサイズに近くなったら属性を解除する
  134.                 setTimeout(removeSize, 500);
  135.             };
  136.             $('.item_visual').on('init', slickInitial);
  137.             // リサイズ時は CLS の影響を受けないため属性を解除する
  138.             $(window).resize(removeSize);
  139.             $('.item_visual').slick({
  140.                 dots: false,
  141.                 arrows: false,
  142.                 responsive: [{
  143.                     breakpoint: 768,
  144.                     settings: {
  145.                         dots: true
  146.                     }
  147.                 }]
  148.             });
  149.             $('.slideThumb').on('click', function() {
  150.                 var index = $(this).attr('data-index');
  151.                 $('.item_visual').slick('slickGoTo', index, false);
  152.             })
  153.         });
  154.     </script>
  155.     <script>
  156.         $(function() {
  157.             $('.add-cart').on('click', function(event) {
  158.                 {% if form.classcategory_id1 is defined %}
  159.                 // 規格1フォームの必須チェック
  160.                 if ($('#classcategory_id1').val() == '__unselected' || $('#classcategory_id1').val() == '') {
  161.                     $('#classcategory_id1')[0].setCustomValidity('{{ '項目が選択されていません'|trans }}');
  162.                     return true;
  163.                 } else {
  164.                     $('#classcategory_id1')[0].setCustomValidity('');
  165.                 }
  166.                 {% endif %}
  167.                 {% if form.classcategory_id2 is defined %}
  168.                 // 規格2フォームの必須チェック
  169.                 if ($('#classcategory_id2').val() == '__unselected' || $('#classcategory_id2').val() == '') {
  170.                     $('#classcategory_id2')[0].setCustomValidity('{{ '項目が選択されていません'|trans }}');
  171.                     return true;
  172.                 } else {
  173.                     $('#classcategory_id2')[0].setCustomValidity('');
  174.                 }
  175.                 {% endif %}
  176.                 // 個数フォームのチェック
  177.                 if ($('#quantity').val() < 1) {
  178.                     $('#quantity')[0].setCustomValidity('{{ '1以上で入力してください。'|trans }}');
  179.                     return true;
  180.                 } else {
  181.                     $('#quantity')[0].setCustomValidity('');
  182.                 }
  183.                 event.preventDefault();
  184.                 $form = $('#form1');
  185.                 $.ajax({
  186.                     url: $form.attr('action'),
  187.                     type: $form.attr('method'),
  188.                     data: $form.serialize(),
  189.                     dataType: 'json',
  190.                     beforeSend: function(xhr, settings) {
  191.                         // Buttonを無効にする
  192.                         $('.add-cart').prop('disabled', true);
  193.                     }
  194.                 }).done(function(data) {
  195.                     // レスポンス内のメッセージをalertで表示
  196.                     $.each(data.messages, function() {
  197.                         $('#ec-modal-header').text(this);
  198.                     });
  199.                     $('.ec-modal').show()
  200.                     // カートブロックを更新する
  201.                     $.ajax({
  202.                         url: "{{ url('block_cart') }}",
  203.                         type: 'GET',
  204.                         dataType: 'html'
  205.                     }).done(function(html) {
  206.                         $('.ec-headerRole__cart').html(html);
  207.                     });
  208.                 }).fail(function(data) {
  209.                     alert('{{ 'カートへの追加に失敗しました。'|trans }}');
  210.                 }).always(function(data) {
  211.                     // Buttonを有効にする
  212.                     $('.add-cart').prop('disabled', false);
  213.                 });
  214.             });
  215.         });
  216.         $('.ec-modal-wrap').on('click', function(e) {
  217.             // モーダル内の処理は外側にバブリングさせない
  218.             e.stopPropagation();
  219.         });
  220.         $('.ec-modal-overlay, .ec-modal, .ec-modal-close, .ec-inlineBtn--cancel').on('click', function() {
  221.             $('.ec-modal').hide()
  222.         });
  223.         const $wrap = document.querySelector('.number-spinner-wrap')
  224.         const $input = $wrap.querySelector('input')
  225.         $wrap.querySelector('.spinner-down').onclick = ()=>{
  226.         $input.stepDown()
  227.         }
  228.         $wrap.querySelector('.spinner-up').onclick = ()=>{
  229.         $input.stepUp()
  230.         }
  231.     </script>
  232.     <script type="application/ld+json">
  233.     {
  234.         "@context": "https://schema.org/",
  235.         "@type": "Product",
  236.         "name": "{{ Product.name }}",
  237.         "image": [
  238.             {% for img in Product.ProductImage %}
  239.                 "{{ app.request.schemeAndHttpHost }}{{ asset(img, 'save_image') }}"{% if not loop.last %},{% endif %}
  240.             {% else %}
  241.                 "{{ app.request.schemeAndHttpHost }}{{ asset(''|no_image_product, 'save_image') }}"
  242.             {% endfor %}
  243.         ],
  244.         "description": "{{ Product.description_list | default(Product.description_detail) | replace({'\n': '', '\r': ''}) | slice(0,300) }}",
  245.         {% if Product.code_min %}
  246.         "sku": "{{ Product.code_min }}",
  247.         {% endif %}
  248.         "offers": {
  249.             "@type": "Offer",
  250.             "url": "{{ url('product_detail', {'id': Product.id}) }}",
  251.             "priceCurrency": "{{ eccube_config.currency }}",
  252.             "price": {{ Product.getPrice02IncTaxMin ? Product.getPrice02IncTaxMin : 0}},
  253.             "availability": "{{ Product.stock_find ? "InStock" : "OutOfStock" }}"
  254.         }
  255.     }
  256.     </script>
  257. {% endblock %}
  258. {% block main %}
  259.     <div class="ec-productRole">
  260.         <div class="product-head">
  261.             {# 関連カテゴリ #}
  262.             {% if Product.ProductCategories is not empty %}
  263.                 <div class="ec-productRole__category">
  264.                     <div class="product-bread">
  265.                         {% for ProductCategory in Product.ProductCategories %}
  266.                             {% if ProductCategory.Category.name != "販売" and ProductCategory.Category.name != "おすすめ商品" %}
  267.                             <a href="{{ url('product_list') }}?category_id={{ ProductCategory.Category.id }}" class="maru">{{ ProductCategory.Category.name }}</a>
  268.                             {% endif %}
  269.                         {% endfor %}
  270.                     </div>
  271.                     {# for ProductCategory in Product.ProductCategories %}
  272.                         <ul>
  273.                             <li>
  274.                                 {# for Category in ProductCategory.Category.path %}
  275.                                     <a href="{{ url('product_list') }}?category_id={{ Category.id }}">{{ Category.name }}</a> {%- if loop.last == false %}
  276.                                     <span>></span>{% endif -%}
  277.                                 {% endfor }
  278.                             </li>
  279.                         </ul>
  280.                     {% endfor #}
  281.                 </div>
  282.             {% endif %}
  283.         </div>
  284.         <div class="product-bigbox">
  285.             <div>
  286.                 {# 商品名 #}
  287.                 
  288.                     <h2 class="maru product-name">{{ Product.name }}</h2>
  289.                 
  290.             </div>
  291.             <div class="ec-grid2">
  292.                     
  293.                 <div class="ec-grid2__cell">
  294.                     <div class="ec-sliderItemRole">
  295.                         <div class="item_visual">
  296.                             {% for ProductImage in Product.ProductImage %}
  297.                                 <div class="slide-item"><img src="{{ asset(ProductImage, 'save_image') }}" alt="{{ loop.first ? Product.name : '' }}" width="550" height="550"{% if loop.index > 1 %} loading="lazy"{% endif %}></div>
  298.                             {% else %}
  299.                                 <div class="slide-item"><img src="{{ asset(''|no_image_product, 'save_image') }}" alt="{{ loop.first ? Product.name : '' }}" width="550" height="550"></div>
  300.                             {% endfor %}
  301.                         </div>
  302.                     </div>
  303.                     <a class="lightbox-btn" data-lightbox="photo01" href="{% for ProductImage in Product.ProductImage %}{{ asset(ProductImage, 'save_image') }}{% else %}{{ asset(''|no_image_product, 'save_image') }}{% endfor %}">
  304.                         <span class="lbox maru">カードを拡大表示する</span>
  305.                     </a>
  306.                     {# 通常価格 #}
  307.                     {# if Product.hasProductClass -%}
  308.                         <div class="ec-productRole__priceRegular">
  309.                             {% if Product.getPrice01Min is not null and Product.getPrice01IncTaxMin == Product.getPrice01IncTaxMax %}
  310.                                 <span class="ec-productRole__priceRegularPrice">{{ '通常価格'|trans }}:<span class="price01-default">{{ Product.getPrice01IncTaxMin|price }}</span></span>
  311.                                 <span class="ec-productRole__priceRegularTax">{{ '税込'|trans }}</span>
  312.                             {% elseif Product.getPrice01Min is not null and Product.getPrice01Max is not null %}
  313.                                 <span class="ec-productRole__priceRegularPrice">{{ '通常価格'|trans }}:<span class="price01-default">{{ Product.getPrice01IncTaxMin|price }}~ {{ Product.getPrice01IncTaxMax|price }}</span></span>
  314.                                 <span class="ec-productRole__priceRegularTax">{{ '税込'|trans }}</span>
  315.                             {% endif %}
  316.                         </div>
  317.                     {% else }
  318.                         {% if Product.getPrice01Max is not null %}
  319.                             <span class="ec-productRole__priceRegularPrice">{{ '通常価格'|trans }}:{{ Product.getPrice01IncTaxMin|price }}</span>
  320.                             <span class="ec-productRole__priceRegularTax">{{ '税込'|trans }}</span>
  321.                         {% endif %}
  322.                     {% endif #}
  323.                     {# 販売価格 #}
  324.                     <form action="{{ url('product_add_cart', {id:Product.id}) }}" method="post" id="form1" name="form1">
  325.                         <div class="product-price-bigbox">
  326.                             <div class="product-price">
  327.                                 {% if Product.hasProductClass -%}
  328.                                     {% if Product.getPrice02IncTaxMin == Product.getPrice02IncTaxMax %}
  329.                                         <div class="ec-price">
  330.                                             <span class="ec-price__price price02-default fs40">{{ Product.getPrice02IncTaxMin|number_format }}</span>
  331.                                             <span class="ec-price__tax">{{ '円(税込)'|trans }}</span>
  332.                                         </div>
  333.                                     {% else %}
  334.                                         <div class="ec-price">
  335.                                             <span class="ec-price__price price02-default fs40">{{ Product.getPrice02IncTaxMin|number_format }} ~ {{ Product.getPrice02IncTaxMax|number_format }}</span>
  336.                                             <span class="ec-price__tax">{{ '円(税込)'|trans }}</span>
  337.                                         </div>
  338.                                     {% endif %}
  339.                                 {% else %}
  340.                                     <div class="ec-price">
  341.                                         <span class="ec-price__price fs40">{{ Product.getPrice02IncTaxMin|number_format }}</span>
  342.                                         <span class="ec-price__tax">{{ '円(税込)'|trans }}</span>
  343.                                     </div>
  344.                                 {% endif %}
  345.                             </div>
  346.                         
  347.                         {% if Product.stock_find %}
  348.                             <div class="product-spin"><!--ec-productRole__actions-->
  349.                                 {% if form.classcategory_id1 is defined %}
  350.                                     <div class="ec-select">
  351.                                         {{ form_row(form.classcategory_id1) }}
  352.                                         {{ form_errors(form.classcategory_id1) }}
  353.                                     </div>
  354.                                     {% if form.classcategory_id2 is defined %}
  355.                                         <div class="ec-select">
  356.                                             {{ form_row(form.classcategory_id2) }}
  357.                                             {{ form_errors(form.classcategory_id2) }}
  358.                                         </div>
  359.                                     {% endif %}
  360.                                 {% endif %}
  361.                                 <!--<div class="ec-numberInput"><span>{{ '数量'|trans }}</span>
  362.                                     {{ form_widget(form.quantity) }}
  363.                                     {{ form_errors(form.quantity) }}
  364.                                 </div>-->
  365.                                 <label class="number-spinner-wrap">
  366.                                     <input type="number" id="quantity{{ Product.id }}" name="quantity" required="required" min="1" maxlength="9" class="test5" value="1">
  367.                                     <span class="spinner spinner-down"> <img src="{{ asset('/html/user_data/assets/img/minus.png') }}" class="numcursul" alt=""> </span>
  368.                                     <span class="spinner spinner-up"> <img src="{{ asset('/html/user_data/assets/img/plus.png') }}" class="numcursul" alt=""> </span>
  369.                                 </label>
  370.                             </div>
  371.                         </div>
  372.                             <div class="ec-productRole__btn">
  373.                                 <button type="submit" class="ec-blockBtn--action add-cart maru">
  374.                                     <span class="cartbig">{{ 'カートに入れる'|trans }}</span>
  375.                                 </button>
  376.                             </div>
  377.                         {% else %}
  378.                         </div>
  379.                             <div class="ec-productRole__btn">
  380.                                 <button type="button" class="ec-blockBtn--action " disabled="disabled">
  381.                                     <span class="cartbig">{{ 'ただいま品切れ中です。'|trans }}</span>
  382.                                 </button>
  383.                             </div>
  384.                         {% endif %}
  385.                         
  386.                         {{ form_rest(form) }}
  387.                     </form>
  388.                     <div class="ec-modal">
  389.                         <div class="ec-modal-overlay">
  390.                             <div class="ec-modal-wrap">
  391.                                 <span class="ec-modal-close"><span class="ec-icon"><img src="{{ asset('assets/icon/cross-dark.svg') }}" alt=""/></span></span>
  392.                                 <div id="ec-modal-header" class="text-center">{{ 'カートに追加しました。'|trans }}</div>
  393.                                 <div class="ec-modal-box">
  394.                                     <div class="ec-role">
  395.                                         <span class="ec-inlineBtn--cancel">{{ 'お買い物を続ける'|trans }}</span>
  396.                                         <a href="{{ url('cart') }}" class="ec-inlineBtn--action">{{ 'カートへ進む'|trans }}</a>
  397.                                     </div>
  398.                                 </div>
  399.                             </div>
  400.                         </div>
  401.                     </div>
  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 is_favorite == false %}
  406.                                     <button type="submit" id="favorite" class="maru ec-blockBtn--cancel">
  407.                                         <span class="cartstar">{{ 'お気に入りに追加する'|trans }}</span>
  408.                                         
  409.                                     </button>
  410.                                 {% else %}
  411.                                     <button type="submit" id="favorite" class="maru ec-blockBtn--cancel"
  412.                                             disabled="disabled">
  413.                                         <span class="cartstar">{{ 'お気に入りに追加済です。'|trans }}</span>
  414.                                     </button>
  415.                                 {% endif %}
  416.                             </div>
  417.                         </form>
  418.                     {% endif %}
  419.                 </div>
  420.                 <div class="ec-grid2__cell">
  421.                     <div class="ec-productRole__profile">
  422.                         {# タグ 
  423.                         <ul class="ec-productRole__tags">
  424.                             {% for Tag in Product.Tags %}
  425.                                 <li class="ec-productRole__tag tag_{{ Tag.id }}">{{ Tag }}</li>
  426.                             {% endfor %}
  427.                         </ul>#}
  428.                         {# 商品コード 
  429.                         {% if Product.code_min is not empty %}
  430.                             <div class="ec-productRole__code">
  431.                                 {{ '商品コード'|trans }}: <span class="product-code-default">{{ Product.code_min }}{% if Product.code_min != Product.code_max %} ~ {{ Product.code_max }}{% endif %}</span>
  432.                             </div>
  433.                         {% endif %}#}
  434.                         <div class="ec-productRole__description product-res">
  435.                             {# Product.description_detail|raw|nl2br #}
  436.                             {{ Product.description_detail|raw }}
  437.                             <!--<div class="pro-res-big">
  438.                                 <div class="pro-res-mid2">
  439.                                     <h3>在庫表示につきまして当店では在庫数に応じて在庫状況を表示しております。</h3>
  440.                                     <p>在庫数4以上:在庫あり</p>
  441.                                     <p>在庫数3以下:在庫わずか</p>
  442.                                     <p>在庫数0  :在庫なし</p>
  443.                                 </div>
  444.                             </div>-->
  445.                         </div>
  446.                         <div class="ec-productRole__description product-res">
  447.                             {{ Product.description_list | default('') | nl2br }}
  448.                         </div>
  449.                         {% if Product.freearea %}
  450.                         <div class="ec-productRole__description">
  451.                                 {{ include(template_from_string(Product.freearea)) }}
  452.                         </div>
  453.                         {% endif %}
  454.                         
  455.                     </div>
  456.                 </div>
  457.             </div>
  458.         </div>
  459.     </div>
  460. {% endblock %}