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.         
  102.      
  103.         $('.item_visual').slick({
  104.             dots: false,
  105.             arrows: false,
  106.             responsive: [{
  107.                 breakpoint: 768,
  108.                 settings: {
  109.                     dots: true
  110.                 }
  111.             }]
  112.         });
  113.         $('.slideThumb').on('click', function () {
  114.             var index = $(this).attr('data-index');
  115.             $('.item_visual').slick('slickGoTo', index, false);
  116.         })
  117.     });
  118. </script>
  119. <script>
  120.     $(function () {
  121.         $('.add-cart').on('click', function (event) {
  122.             {% if form.classcategory_id1 is defined %}
  123.             // 規格1フォームの必須チェック
  124.             if ($('#classcategory_id1').val() == '__unselected' || $('#classcategory_id1').val() == '') {
  125.                 $('#classcategory_id1')[0].setCustomValidity('{{ '項目が選択されていません'|trans }}');
  126.                 return true;
  127.             } else {
  128.                 $('#classcategory_id1')[0].setCustomValidity('');
  129.             }
  130.             {% endif %}
  131.             {% if form.classcategory_id2 is defined %}
  132.             // 規格2フォームの必須チェック
  133.             if ($('#classcategory_id2').val() == '__unselected' || $('#classcategory_id2').val() == '') {
  134.                 $('#classcategory_id2')[0].setCustomValidity('{{ '項目が選択されていません'|trans }}');
  135.                 return true;
  136.             } else {
  137.                 $('#classcategory_id2')[0].setCustomValidity('');
  138.             }
  139.             {% endif %}
  140.             // 個数フォームのチェック
  141.             if ($('#quantity').val() < 1) {
  142.                 $('#quantity')[0].setCustomValidity('{{ '1以上で入力してください。'|trans }}');
  143.                 return true;
  144.             } else {
  145.                 $('#quantity')[0].setCustomValidity('');
  146.             }
  147.             event.preventDefault();
  148.             $form = $('#form1');
  149.             $.ajax({
  150.                 url: $form.attr('action'),
  151.                 type: $form.attr('method'),
  152.                 data: $form.serialize(),
  153.                 dataType: 'json',
  154.                 beforeSend: function (xhr, settings) {
  155.                     // Buttonを無効にする
  156.                     $('.add-cart').prop('disabled', true);
  157.                 }
  158.             }).done(function (data) {
  159.                 // レスポンス内のメッセージをalertで表示
  160.                 $.each(data.messages, function () {
  161.                     $('#ec-modal-header').text(this);
  162.                 });
  163.                 $('.ec-modal').show()
  164.                 // カートブロックを更新する
  165.                 $.ajax({
  166.                     url: "{{ url('block_cart') }}",
  167.                     type: 'GET',
  168.                     dataType: 'html'
  169.                 }).done(function (html) {
  170.                     $('.ec-headerRole__cart').html(html);
  171.                 });
  172.             }).fail(function (data) {
  173.                 alert('{{ 'カートへの追加に失敗しました。'|trans }}');
  174.             }).always(function (data) {
  175.                 // Buttonを有効にする
  176.                 $('.add-cart').prop('disabled', false);
  177.             });
  178.         });
  179.     });
  180.     $('.ec-modal-wrap').on('click', function (e) {
  181.         // モーダル内の処理は外側にバブリングさせない
  182.         e.stopPropagation();
  183.     });
  184.     $('.ec-modal-overlay, .ec-modal, .ec-modal-close, .ec-inlineBtn--cancel').on('click', function () {
  185.         $('.ec-modal').hide()
  186.     });
  187. </script>
  188. <script type="application/ld+json">
  189.     {
  190.         "@context": "https://schema.org/",
  191.         "@type": "Product",
  192.         "name": "{{ Product.name }}",
  193.         "image": [
  194.             {% for img in Product.ProductImage %}
  195.                 "{{ app.request.schemeAndHttpHost }}{{ asset(img, 'save_image') }}"{% if not loop.last %},{% endif %}
  196.             {% else %}
  197.                 "{{ app.request.schemeAndHttpHost }}{{ asset(''|no_image_product, 'save_image') }}"
  198.             {% endfor %}
  199.         ],
  200.         "description": "{{ Product.description_list | default(Product.description_detail) | replace({'\n': '', '\r': ''}) | slice(0,300) }}",
  201.         {% if Product.code_min %}
  202.         "sku": "{{ Product.code_min }}",
  203.         {% endif %}
  204.         "offers": {
  205.             "@type": "Offer",
  206.             "url": "{{ url('product_detail', {'id': Product.id}) }}",
  207.             "priceCurrency": "{{ eccube_config.currency }}",
  208.             "price": {{ Product.getPrice02IncTaxMin ? Product.getPrice02IncTaxMin : 0}},
  209.             "availability": "{{ Product.stock_find ? "InStock" : "OutOfStock" }}"
  210.         }
  211.     }
  212.     </script>
  213. {% endblock %}
  214. {% block main %}
  215.     {# パンくず #}
  216.     {% include 'Block/breadcrumb.twig' %}
  217. <div class="ec-productRole">
  218.     <div class="ec-grid2">
  219.         <div class="ec-grid2__cell">
  220.             <div class="ec-sliderItemRole">
  221.                 <div class="item_visual">
  222.                     {% for ProductImage in Product.ProductImage %}
  223.                     <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>
  224.                     {% else %}
  225.                     <div class="slide-item"><img src="{{ asset(''|no_image_product, 'save_image') }}" alt="{{ loop.first ? Product.name : '' }}" width="550" height="550"></div>
  226.                     {% endfor %}
  227.                 </div>
  228.                 <div class="item_nav">
  229.                     {% for ProductImage in Product.ProductImage %}
  230.                     <div class="slideThumb" data-index="{{ loop.index0 }}"><img src="{{ asset(ProductImage, 'save_image') }}" alt="" width="133" height="133" loading="lazy"></div>
  231.                     {% endfor %}
  232.                 </div>
  233.             </div>
  234.         </div>
  235.         <div class="ec-grid2__cell">
  236.             <div class="ec-productRole__profile">
  237.                 {# タグ #}
  238.                 <ul class="ec-productRole__tags">
  239.                     {% for Tag in Product.Tags %}
  240.                     <li class="ec-productRole__tag tag_{{ Tag.id }}"></li>
  241.                     {% endfor %}
  242.                 </ul>
  243.                 {# 商品名 #}
  244.                 <div class="ec-productRole__title">
  245.                     <h2 class="ec-headingTitle">{{ Product.name }}</h2>
  246.                 </div>
  247.                 {# 一覧説明 #}
  248.                 <div class="ec-productRole__description_list">
  249.                     <div class="ec-headingTitle">{{ Product.description_list|raw }}</div>
  250.                    
  251.                 </div>
  252.                 {# 通常価格 #}
  253.                 {% if Product.hasProductClass -%}
  254.                 <div class="ec-productRole__priceRegular">
  255.                     {% if Product.getPrice01Min is not null and Product.getPrice01IncTaxMin == Product.getPrice01IncTaxMax %}
  256.                     <span class="ec-productRole__priceRegularPrice">{{ '通常価格'|trans }}:<span class="price01-default">{{ Product.getPrice01IncTaxMin|number_format }}円</span></span>
  257.                     <span class="ec-productRole__priceRegularTax">{{ '(税込)'|trans }}</span>
  258.                     {% elseif Product.getPrice01Min is not null and Product.getPrice01Max is not null %}
  259.                     <span class="ec-productRole__priceRegularPrice">{{ '通常価格'|trans }}:<span class="price01-default">{{ Product.getPrice01IncTaxMin|number_format }}~ {{ Product.getPrice01IncTaxMax|number_format }}円</span></span>
  260.                     <span class="ec-productRole__priceRegularTax">{{ '(税込)'|trans }}</span>
  261.                     {% endif %}
  262.                 </div>
  263.                 {% else %}
  264.                 {% if Product.getPrice01Max is not null %}
  265.                 <span class="ec-productRole__priceRegularPrice">{{ '通常価格'|trans }}:{{ Product.getPrice01IncTaxMin|number_format }}円</span>
  266.                 <span class="ec-productRole__priceRegularTax">{{ '(税込)'|trans }}</span>
  267.                 {% endif %}
  268.                 {% endif %}
  269.                 {# 販売価格 #}
  270.                 <div class="ec-productRole__price">
  271.                     {% if Product.hasProductClass -%}
  272.                     {% if Product.getPrice02IncTaxMin == Product.getPrice02IncTaxMax %}
  273.                     <div class="ec-price">
  274.                         <span class="ec-price__price price02-default">{{ Product.getPrice02IncTaxMin|number_format }}円</span>
  275.                         <span class="ec-price__tax">{{ '(税込)'|trans }}</span>
  276.                     </div>
  277.                     {% else %}
  278.                     <div class="ec-price">
  279.                         <span class="ec-price__price price02-default">{{ Product.getPrice02IncTaxMin|number_format }} ~ {{ Product.getPrice02IncTaxMax|number_format }}円</span>
  280.                         <span class="ec-price__tax">{{ '(税込)'|trans }}</span>
  281.                     </div>
  282.                     {% endif %}
  283.                     {% else %}
  284.                     <div class="ec-price">
  285.                         <span class="ec-price__price">{{ Product.getPrice02IncTaxMin|number_format }}円</span>
  286.                         <span class="ec-price__tax">{{ '(税込)'|trans }}</span>
  287.                     </div>
  288.                     {% endif %}
  289.                 </div>
  290.                 {# 商品コード #}
  291.                 <!--
  292.                     {% if Product.code_min is not empty %}
  293.                         <div class="ec-productRole__code">
  294.                             {{ '商品コード'|trans }}: <span class="product-code-default">{{ Product.code_min }}{% if Product.code_min != Product.code_max %} ~ {{ Product.code_max }}{% endif %}</span>
  295.                         </div>
  296.                     {% endif %}
  297.                     -->
  298.                 {# 関連カテゴリ #}
  299.                 {#
  300.                 {% if Product.ProductCategories is not empty %}
  301.                 <div class="ec-productRole__category">
  302.                     <div>{{ '関連カテゴリ'|trans }}</div>
  303.                     {% for ProductCategory in Product.ProductCategories %}
  304.                     <ul>
  305.                         <li>
  306.                             {% for Category in ProductCategory.Category.path %}
  307.                             <a href="{{ url('product_list') }}?category_id={{ Category.id }}">{{ Category.name }}</a> {%- if loop.last == false %}
  308.                             <span>></span>{% endif -%}
  309.                             {% endfor %}
  310.                         </li>
  311.                     </ul>
  312.                     {% endfor %}
  313.                 </div>
  314.                 {% endif %}
  315.                 #}
  316.                 <div id="cart_btn_area">
  317.                     <form action="{{ url('product_add_cart', {id:Product.id}) }}" method="post" id="form1" name="form1" class="productForm">
  318.                         {% if Product.stock_find %}
  319.                         <div class="ec-productRole__actions">
  320.                             {% if form.classcategory_id1 is defined %}
  321.                             <div class="ec-select">
  322.                                 {{ form_row(form.classcategory_id1) }}
  323.                                 {{ form_errors(form.classcategory_id1) }}
  324.                             </div>
  325.                             {% if form.classcategory_id2 is defined %}
  326.                             <div class="ec-select">
  327.                                 {{ form_row(form.classcategory_id2) }}
  328.                                 {{ form_errors(form.classcategory_id2) }}
  329.                             </div>
  330.                             {% endif %}
  331.                             {% endif %}
  332.                             <div class="ec-numberInput"><span>{{ '数量'|trans }}</span>
  333.                                 {{ form_widget(form.quantity) }}
  334.                                 {{ form_errors(form.quantity) }}
  335.                             </div>
  336.                         </div>
  337.                         <div class="ec-productRole__btn">
  338.                             <button type="submit" class="ec-blockBtn--action add-cart">
  339.                                 {{ 'カートに入れる'|trans }}
  340.                             </button>
  341.                         </div>
  342.                         {% else %}
  343.                         <div class="ec-productRole__btn">
  344.                             <button type="button" class="ec-blockBtn--action" disabled="disabled">
  345.                                 {{ 'オンライン在庫なし'|trans }}
  346.                             </button>
  347.                         </div>
  348.                         {% endif %}
  349.                         {{ form_rest(form) }}
  350.                     </form>
  351.                     <div class="ec-modal">
  352.                         <div class="ec-modal-overlay">
  353.                             <div class="ec-modal-wrap">
  354.                                 <span class="ec-modal-close"><span class="ec-icon"><img src="{{ asset('assets/icon/cross-dark.svg') }}" alt="" /></span></span>
  355.                                 <div id="ec-modal-header" class="text-center">{{ 'カートに追加しました。'|trans }}</div>
  356.                                 <div class="ec-modal-box">
  357.                                     <div class="ec-role">
  358.                                         <span class="ec-inlineBtn--cancel">{{ 'お買い物を続ける'|trans }}</span>
  359.                                         <a href="{{ url('cart') }}" class="ec-inlineBtn--action">{{ 'カートへ進む'|trans }}</a>
  360.                                     </div>
  361.                                 </div>
  362.                             </div>
  363.                         </div>
  364.                     </div>
  365.                     
  366.                     {% if BaseInfo.option_favorite_product %}
  367.                     <form action="{{ url('product_add_favorite', {id:Product.id}) }}" method="post">
  368.                         <div class="ec-productRole__btn">
  369.                             {% if is_favorite == false %}
  370.                             <button type="submit" id="favorite" class="favoriteBtn--add">
  371.                                 {{ 'お気に入りに追加'|trans }}
  372.                             </button>
  373.                             {% else %}
  374.                             <button type="submit" id="favorite" class="favoriteBtn--done" disabled="disabled">{{ 'お気に入りに追加済です。'|trans }}
  375.                             </button>
  376.                             {% endif %}
  377.                         </div>
  378.                     </form>
  379.                     {% endif %}
  380.                     
  381.                 </div>
  382.                 <div class="ec-productRole__description">{{ Product.description_detail|raw|nl2br }}</div>
  383.                 {% if Product.freearea %}
  384.                 <div class="ec-productRole__description">{{ include(template_from_string(Product.freearea|raw|nl2br), sandboxed = true) }}</div>
  385.                 {% endif %}
  386.             </div>
  387.         </div>
  388.     </div>
  389. </div>
  390. {% endblock %}