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