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