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

Open in your IDE?
  1. {#
  2. This file is part of EC-CUBE
  3. Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
  4. http://www.ec-cube.co.jp/
  5. For the full copyright and license information, please view the LICENSE
  6. file that was distributed with this source code.
  7. #}
  8. {% extends 'default_frame.twig' %}
  9. {% set body_class = 'product_page' %}
  10. {% block stylesheet %}
  11.     <style>
  12.         .slick-slider {
  13.             margin-bottom: 30px;
  14.         }
  15.         .slick-dots {
  16.             position: absolute;
  17.             bottom: -45px;
  18.             display: block;
  19.             width: 100%;
  20.             padding: 0;
  21.             list-style: none;
  22.             text-align: center;
  23.         }
  24.         .slick-dots li {
  25.             position: relative;
  26.             display: inline-block;
  27.             width: 20px;
  28.             height: 20px;
  29.             margin: 0 5px;
  30.             padding: 0;
  31.             cursor: pointer;
  32.         }
  33.         .slick-dots li button {
  34.             font-size: 0;
  35.             line-height: 0;
  36.             display: block;
  37.             width: 20px;
  38.             height: 20px;
  39.             padding: 5px;
  40.             cursor: pointer;
  41.             color: transparent;
  42.             border: 0;
  43.             outline: none;
  44.             background: transparent;
  45.         }
  46.         .slick-dots li button:hover,
  47.         .slick-dots li button:focus {
  48.             outline: none;
  49.         }
  50.         .slick-dots li button:hover:before,
  51.         .slick-dots li button:focus:before {
  52.             opacity: 1;
  53.         }
  54.         .slick-dots li button:before {
  55.             content: " ";
  56.             line-height: 20px;
  57.             position: absolute;
  58.             top: 0;
  59.             left: 0;
  60.             width: 12px;
  61.             height: 12px;
  62.             text-align: center;
  63.             opacity: .25;
  64.             background-color: black;
  65.             border-radius: 50%;
  66.         }
  67.         .slick-dots li.slick-active button:before {
  68.             opacity: .75;
  69.             background-color: black;
  70.         }
  71.         .slick-dots li button.thumbnail img {
  72.             width: 0;
  73.             height: 0;
  74.         }
  75.     </style>
  76. {% endblock %}
  77. {% block javascript %}
  78.     <script>
  79.         eccube.classCategories = {{ class_categories_as_json(Product)|raw }};
  80.         // 規格2に選択肢を割り当てる。
  81.         function fnSetClassCategories(form, classcat_id2_selected) {
  82.             var $form = $(form);
  83.             var product_id = $form.find('input[name=product_id]').val();
  84.             var $sele1 = $form.find('select[name=classcategory_id1]');
  85.             var $sele2 = $form.find('select[name=classcategory_id2]');
  86.             eccube.setClassCategories($form, product_id, $sele1, $sele2, classcat_id2_selected);
  87.         }
  88.         {% if form.classcategory_id2 is defined %}
  89.         fnSetClassCategories(
  90.             $('#form1'), {{ form.classcategory_id2.vars.value|json_encode|raw }}
  91.         );
  92.         {% elseif form.classcategory_id1 is defined %}
  93.         eccube.checkStock($('#form1'), {{ Product.id }}, {{ form.classcategory_id1.vars.value|json_encode|raw }}, null);
  94.         {% endif %}
  95.     </script>
  96.     <script>
  97.         $(function() {
  98.             // bfcache無効化
  99.             $(window).bind('pageshow', function(event) {
  100.                 if (event.originalEvent.persisted) {
  101.                     location.reload(true);
  102.                 }
  103.             });
  104.             $('.item_visual').slick({
  105.                 dots: false,
  106.                 arrows: false,
  107.                 responsive: [{
  108.                     breakpoint: 768,
  109.                     settings: {
  110.                         dots: true
  111.                     }
  112.                 }]
  113.             });
  114.             $('.slide-thumb').on('click', function() {
  115.                 var index = $(this).attr('data-index');
  116.                 $('.item_visual').slick('slickGoTo', index, false);
  117.             })
  118.         });
  119.     </script>
  120.     <script>
  121.         $(function() {
  122.             $('.add-cart').on('click', function(event) {
  123.                 {% if form.classcategory_id1 is defined %}
  124.                 // 規格1フォームの必須チェック
  125.                 if ($('#classcategory_id1').val() == '__unselected' || $('#classcategory_id1').val() == '') {
  126.                     $('#classcategory_id1')[0].setCustomValidity('{{ '項目が選択されていません'|trans }}');
  127.                     return true;
  128.                 } else {
  129.                     $('#classcategory_id1')[0].setCustomValidity('');
  130.                 }
  131.                 {% endif %}
  132.                 {% if form.classcategory_id2 is defined %}
  133.                 // 規格2フォームの必須チェック
  134.                 if ($('#classcategory_id2').val() == '__unselected' || $('#classcategory_id2').val() == '') {
  135.                     $('#classcategory_id2')[0].setCustomValidity('{{ '項目が選択されていません'|trans }}');
  136.                     return true;
  137.                 } else {
  138.                     $('#classcategory_id2')[0].setCustomValidity('');
  139.                 }
  140.                 {% endif %}
  141.                 // 個数フォームのチェック
  142.                 if ($('#quantity').val() < 1) {
  143.                     $('#quantity')[0].setCustomValidity('{{ '1以上で入力してください。'|trans }}');
  144.                     return true;
  145.                 } else {
  146.                     $('#quantity')[0].setCustomValidity('');
  147.                 }
  148.                 event.preventDefault();
  149.                 $form = $('#form1');
  150.                 $.ajax({
  151.                     url: $form.attr('action'),
  152.                     type: $form.attr('method'),
  153.                     data: $form.serialize(),
  154.                     dataType: 'json',
  155.                     beforeSend: function(xhr, settings) {
  156.                         // Buttonを無効にする
  157.                         $('.add-cart').prop('disabled', true);
  158.                     }
  159.                 }).done(function(data) {
  160.                     // レスポンス内のメッセージをalertで表示
  161.                     $.each(data.messages, function() {
  162.                         $('#ec-modal-header').html(this);
  163.                     });
  164.                     $('.ec-modal').show()
  165.                     // カートブロックを更新する
  166.                     $.ajax({
  167.                         url: "{{ url('block_cart') }}",
  168.                         type: 'GET',
  169.                         dataType: 'html'
  170.                     }).done(function(html) {
  171.                         $('.ec-headerRole__cart').html(html);
  172.                     });
  173.                 }).fail(function(data) {
  174.                     alert('{{ 'カートへの追加に失敗しました。'|trans }}');
  175.                 }).always(function(data) {
  176.                     // Buttonを有効にする
  177.                     $('.add-cart').prop('disabled', false);
  178.                 });
  179.             });
  180.         });
  181.         $('.ec-modal-wrap').on('click', function(e) {
  182.             // モーダル内の処理は外側にバブリングさせない
  183.             e.stopPropagation();
  184.         });
  185.         $('.ec-modal-overlay, .ec-modal, .ec-modal-close, .ec-inlineBtn--cancel').on('click', function() {
  186.             $('.ec-modal').hide()
  187.         });
  188.     </script>
  189.     <script type="application/ld+json">
  190.     {
  191.         "@context": "https://schema.org/",
  192.         "@type": "Product",
  193.         "name": "{{ Product.name }}",
  194.         "image": [
  195.             {% for img in Product.ProductImage %}
  196.                 "{{ app.request.schemeAndHttpHost }}{{ asset(img, 'save_image') }}"{% if not loop.last %},{% endif %}
  197.             {% else %}
  198.                 "{{ app.request.schemeAndHttpHost }}{{ asset(''|no_image_product, 'save_image') }}"
  199.             {% endfor %}
  200.         ],
  201.         "description": "{{ Product.description_list | default(Product.description_detail) | replace({'\n': '', '\r': ''}) | slice(0,300) }}",
  202.         {% if Product.code_min %}
  203.         "sku": "{{ Product.code_min }}",
  204.         {% endif %}
  205.         "offers": {
  206.             "@type": "Offer",
  207.             "url": "{{ url('product_detail', {'id': Product.id}) }}",
  208.             "priceCurrency": "{{ eccube_config.currency }}",
  209.             "price": {{ Product.getPrice02IncTaxMin }},
  210.             "availability": "{{ Product.stock_find ? "InStock" : "OutOfStock" }}"
  211.         }
  212.     }
  213.     </script>
  214. {% endblock %}
  215. {% block main %}
  216.     <div class="ec-productRole mt-4">
  217.         <div class="row">
  218.             <div class="col-12 col-lg-6">
  219.                 <div class="ec-sliderItemRole px-0">
  220.                     <div class="item_visual">
  221.                         {% for ProductImage in Product.ProductImage %}
  222.                             <div class="slide-item"><img src="{{ asset(ProductImage, 'save_image') }}" alt="{{ loop.first ? Product.name : '' }}"></div>
  223.                         {% else %}
  224.                             <div class="slide-item"><img src="{{ asset(''|no_image_product, 'save_image') }}" alt="{{ loop.first ? Product.name : '' }}" /></div>
  225.                         {% endfor %}
  226.                     </div>
  227.                     <div class="item_nav">
  228.                         <div class="row" style="width: 100%;">
  229.                             {% for ProductImage in Product.ProductImage %}
  230.                                 <div class="slide-thumb col-4" data-index="{{ loop.index0 }}"><img class="img-fluid" src="{{ asset(ProductImage, 'save_image') }}" alt=""></div>
  231.                             {% endfor %}
  232.                         </div>
  233.                     </div>
  234.                 </div>
  235.             </div>
  236.             <div class="col-12 col-lg-6">
  237.                 <div class="ec-productRole__profile ml-0">
  238.                     {# 商品名 #}
  239.                     <div class="ec-productRole__title">
  240.                         <h2 class="ec-headingTitle">{{ Product.name }}</h2>
  241.                     </div>
  242.                     {# タグ #}
  243.                     <ul class="ec-productRole__tags">
  244.                         {% for Tag in Product.Tags %}
  245.                             <li class="ec-productRole__tag tag_{{ Tag.id }}">{{ Tag }}</li>
  246.                         {% endfor %}
  247.                     </ul>
  248.                     {# 通常価格 #}
  249.                     {% if Product.hasProductClass -%}
  250.                         <div class="ec-productRole__priceRegular">
  251.                             {% if Product.getPrice01Min is not null and Product.getPrice01IncTaxMin == Product.getPrice01IncTaxMax %}
  252.                                 <span class="ec-productRole__priceRegularPrice">{{ '通常価格'|trans }}:<span class="price01-default">{{ Product.getPrice01IncTaxMin|price }}</span></span>
  253.                                 <span class="ec-productRole__priceRegularTax">{{ '税込'|trans }}</span>
  254.                             {% elseif Product.getPrice01Min is not null and Product.getPrice01Max is not null %}
  255.                                 <span class="ec-productRole__priceRegularPrice">{{ '通常価格'|trans }}:<span class="price01-default">{{ Product.getPrice01IncTaxMin|price }}~ {{ Product.getPrice01IncTaxMax|price }}</span></span>
  256.                                 <span class="ec-productRole__priceRegularTax">{{ '税込'|trans }}</span>
  257.                             {% endif %}
  258.                         </div>
  259.                     {% else %}
  260.                         {% if Product.getPrice01Max is not null %}
  261.                             <span class="ec-productRole__priceRegularPrice">{{ '通常価格'|trans }}:{{ Product.getPrice01IncTaxMin|price }}</span>
  262.                             <span class="ec-productRole__priceRegularTax">{{ '税込'|trans }}</span>
  263.                         {% endif %}
  264.                     {% endif %}
  265.                     {# 販売価格 #}
  266.                     <div class="ec-productRole__price">
  267.                         {% if Product.hasProductClass -%}
  268.                             {% if Product.getPrice02IncTaxMin == Product.getPrice02IncTaxMax %}
  269.                                 <div class="ec-price">
  270.                                     <span class="ec-price__price price02-default">{{ Product.getPrice02IncTaxMin|price }}</span>
  271.                                     <span class="ec-price__tax">{{ '税込'|trans }}</span>
  272.                                 </div>
  273.                             {% else %}
  274.                                 <div class="ec-price">
  275.                                     <span class="ec-price__price price02-default">{{ Product.getPrice02IncTaxMin|price }} ~ {{ Product.getPrice02IncTaxMax|price }}</span>
  276.                                     <span class="ec-price__tax">{{ '税込'|trans }}</span>
  277.                                 </div>
  278.                             {% endif %}
  279.                         {% else %}
  280.                             <div class="ec-price">
  281.                                 <span class="ec-price__price">{{ Product.getPrice02IncTaxMin|price }}</span>
  282.                                 <span class="ec-price__tax">{{ '税込'|trans }}</span>
  283.                             </div>
  284.                         {% endif %}
  285.                     </div>
  286.                     {# 商品コード #}
  287.                     {% if Product.code_min is not empty %}
  288.                         <div class="ec-productRole__code">
  289.                             {{ '商品コード'|trans }}: <span class="product-code-default">{{ Product.code_min }}{% if Product.code_min != Product.code_max %} ~ {{ Product.code_max }}{% endif %}</span>
  290.                         </div>
  291.                     {% endif %}
  292.                     {# 関連カテゴリ #}
  293.                     {% if Product.ProductCategories is not empty %}
  294.                         <div class="ec-productRole__category">
  295.                             <div>{{ '関連カテゴリ'|trans }}</div>
  296.                             {% for ProductCategory in Product.ProductCategories %}
  297.                                 <ul>
  298.                                     <li>
  299.                                         {% for Category in ProductCategory.Category.path %}
  300.                                             <a href="{{ url('product_list') }}?category_id={{ Category.id }}">{{ Category.name }}</a> {%- if loop.last == false %}
  301.                                             <span>></span>{% endif -%}
  302.                                         {% endfor %}
  303.                                     </li>
  304.                                 </ul>
  305.                             {% endfor %}
  306.                         </div>
  307.                     {% endif %}
  308.                     <form action="{{ url('product_add_cart', {id:Product.id}) }}" method="post" id="form1" name="form1">
  309.                         {% if Product.stock_find %}
  310.                             <div class="ec-productRole__actions">
  311.                                 {% if form.classcategory_id1 is defined %}
  312.                                     <div class="ec-select">
  313.                                         {{ form_widget(form.classcategory_id1) }}
  314.                                         {{ form_errors(form.classcategory_id1) }}
  315.                                     </div>
  316.                                     {% if form.classcategory_id2 is defined %}
  317.                                         <div class="ec-select">
  318.                                             {{ form_widget(form.classcategory_id2) }}
  319.                                             {{ form_errors(form.classcategory_id2) }}
  320.                                         </div>
  321.                                     {% endif %}
  322.                                 {% endif %}
  323.                                 <div class="ec-numberInput"><span>{{ '数量'|trans }}</span>
  324.                                     {{ form_widget(form.quantity) }}
  325.                                     {{ form_errors(form.quantity) }}
  326.                                 </div>
  327.                             </div>
  328.                             <div class="ec-productRole__btn">
  329.                                 <button type="submit" class="ec-blockBtn--action add-cart">
  330.                                     {{ 'カートに入れる'|trans }}
  331.                                 </button>
  332.                             </div>
  333.                         {% else %}
  334.                             <div class="ec-productRole__btn">
  335.                                 <button type="button" class="ec-blockBtn--action" disabled="disabled">
  336.                                     {{ 'ただいま品切れ中です。'|trans }}
  337.                                 </button>
  338.                             </div>
  339.                         {% endif %}
  340.                         {{ form_rest(form) }}
  341.                     </form>
  342.                     <div class="ec-modal">
  343.                         <div class="ec-modal-overlay">
  344.                             <div class="ec-modal-wrap">
  345.                                 <span class="ec-modal-close"><span class="ec-icon"><img src="{{ asset('assets/icon/cross-dark.svg') }}" alt=""/></span></span>
  346.                                 <div id="ec-modal-header" class="text-center">{{ 'カートに追加しました。'|trans }}</div>
  347.                                 <div class="ec-modal-box">
  348.                                     <div class="ec-role">
  349.                                         <span class="ec-inlineBtn--cancel">{{ 'お買い物を続ける'|trans }}</span>
  350.                                         <a href="{{ url('cart') }}" class="ec-inlineBtn--action">{{ 'カートへ進む'|trans }}</a>
  351.                                     </div>
  352.                                 </div>
  353.                             </div>
  354.                         </div>
  355.                     </div>
  356.                     {% if BaseInfo.option_favorite_product %}
  357.                         <form action="{{ url('product_add_favorite', {id:Product.id}) }}" method="post">
  358.                             <div class="ec-productRole__btn">
  359.                                 {% if is_favorite == false %}
  360.                                     <button type="submit" id="favorite" class="ec-blockBtn--cancel">
  361.                                         {{ 'お気に入りに追加'|trans }}
  362.                                     </button>
  363.                                 {% else %}
  364.                                     <button type="submit" id="favorite" class="ec-blockBtn--cancel"
  365.                                             disabled="disabled">{{ 'お気に入りに追加済です。'|trans }}
  366.                                     </button>
  367.                                 {% endif %}
  368.                             </div>
  369.                         </form>
  370.                     {% endif %}
  371.                     <div class="ec-productRole__description">{{ Product.description_detail|raw|nl2br }}
  372.                     </div>
  373.                 </div>
  374.             </div>
  375.         </div>
  376.         {% if Product.freearea %}
  377.              <div class="ec-productRole__description">
  378.                  {{ include(template_from_string(Product.freearea)) }}
  379.             </div>
  380.         {% endif %}
  381.     </div>
  382. {% endblock %}