app/template/default/Product/detail.twig line 1

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