app/template/sakecabinet/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.     gtag('event', 'view_item', {
  80.         currency: 'JPY',
  81.         value: {{ Product.getPrice02IncTaxMin }},
  82.         items: [{
  83.         item_id: '{{ Product.id }}',
  84.         item_name: '{{ Product.name }}',
  85.         price: {{ Product.getPrice02IncTaxMin }},
  86.         currency: 'JPY'
  87.         }]
  88.     });
  89.     </script>
  90.     <script>
  91.         eccube.classCategories = {{ class_categories_as_json(Product)|raw }};
  92.         // 規格2に選択肢を割り当てる。
  93.         function fnSetClassCategories(form, classcat_id2_selected) {
  94.             var $form = $(form);
  95.             var product_id = $form.find('input[name=product_id]').val();
  96.             var $sele1 = $form.find('select[name=classcategory_id1]');
  97.             var $sele2 = $form.find('select[name=classcategory_id2]');
  98.             eccube.setClassCategories($form, product_id, $sele1, $sele2, classcat_id2_selected);
  99.         }
  100.         {% if form.classcategory_id2 is defined %}
  101.         fnSetClassCategories(
  102.             $('#form1'), {{ form.classcategory_id2.vars.value|json_encode|raw }}
  103.         );
  104.         {% elseif form.classcategory_id1 is defined %}
  105.         eccube.checkStock($('#form1'), {{ Product.id }}, {{ form.classcategory_id1.vars.value|json_encode|raw }}, null);
  106.         {% endif %}
  107.     </script>
  108.     <script>
  109.         $(function() {
  110.             // bfcache無効化
  111.             $(window).bind('pageshow', function(event) {
  112.                 if (event.originalEvent.persisted) {
  113.                     location.reload(true);
  114.                 }
  115.             });
  116.             $('.item_visual').slick({
  117.                 dots: false,
  118.                 arrows: false,
  119.                 responsive: [{
  120.                     breakpoint: 768,
  121.                     settings: {
  122.                         dots: true
  123.                     }
  124.                 }]
  125.             });
  126.             $('.slideThumb').on('click', function() {
  127.                 var index = $(this).attr('data-index');
  128.                 $('.item_visual').slick('slickGoTo', index, false);
  129.             })
  130.         });
  131.     </script>
  132.     <script>
  133.         $(function() {
  134.             $('.add-cart').on('click', function(event) {
  135.                 {% if form.classcategory_id1 is defined %}
  136.                 // 規格1フォームの必須チェック
  137.                 if ($('#classcategory_id1').val() == '__unselected' || $('#classcategory_id1').val() == '') {
  138.                     $('#classcategory_id1')[0].setCustomValidity('{{ '項目が選択されていません'|trans }}');
  139.                     return true;
  140.                 } else {
  141.                     $('#classcategory_id1')[0].setCustomValidity('');
  142.                 }
  143.                 {% endif %}
  144.                 {% if form.classcategory_id2 is defined %}
  145.                 // 規格2フォームの必須チェック
  146.                 if ($('#classcategory_id2').val() == '__unselected' || $('#classcategory_id2').val() == '') {
  147.                     $('#classcategory_id2')[0].setCustomValidity('{{ '項目が選択されていません'|trans }}');
  148.                     return true;
  149.                 } else {
  150.                     $('#classcategory_id2')[0].setCustomValidity('');
  151.                 }
  152.                 {% endif %}
  153.                 // 個数フォームのチェック
  154.                 if ($('#quantity').val() < 1) {
  155.                     $('#quantity')[0].setCustomValidity('{{ '1以上で入力してください。'|trans }}');
  156.                     return true;
  157.                 } else {
  158.                     $('#quantity')[0].setCustomValidity('');
  159.                 }
  160.                 event.preventDefault();
  161.                 $form = $('#form1');
  162.                 $.ajax({
  163.                     url: $form.attr('action'),
  164.                     type: $form.attr('method'),
  165.                     data: $form.serialize(),
  166.                     dataType: 'json',
  167.                     beforeSend: function(xhr, settings) {
  168.                         // Buttonを無効にする
  169.                         $('.add-cart').prop('disabled', true);
  170.                     }
  171.                 }).done(function(data) {
  172.                     // レスポンス内のメッセージをalertで表示
  173.                     $.each(data.messages, function() {
  174.                         $('#ec-modal-header').html(this);
  175.                     });
  176.                     $('.ec-modal').show()
  177.                     // カートブロックを更新する
  178.                     $.ajax({
  179.                         url: "{{ url('block_cart') }}",
  180.                         type: 'GET',
  181.                         dataType: 'html'
  182.                     }).done(function(html) {
  183.                         $('.ec-headerRole__cart').html(html);
  184.                     });
  185.                 }).fail(function(data) {
  186.                     alert('{{ 'カートへの追加に失敗しました。'|trans }}');
  187.                 }).always(function(data) {
  188.                     // Buttonを有効にする
  189.                     $('.add-cart').prop('disabled', false);
  190.                 });
  191.             });
  192.         });
  193.         $('.ec-modal-overlay, .ec-modal .ec-inlineBtn--cancel').on('click', function() {
  194.             $('.ec-modal').hide()
  195.         });
  196.     </script>
  197. {% endblock %}
  198. {% block main %}
  199.     <div class="ec-productRole">
  200.         <div class="ec-grid2">
  201.             <div class="ec-grid2__cell">
  202.                 <div class="ec-sliderItemRole">
  203.                     <div class="item_visual">
  204.                         {% for ProductImage in Product.ProductImage %}
  205.                             <div class="slide-item"><img src="{{ asset(ProductImage, 'save_image') }}"></div>
  206.                         {% else %}
  207.                             <div class="slide-item"><img src="{{ asset(''|no_image_product, 'save_image') }}"/></div>
  208.                         {% endfor %}
  209.                     </div>
  210.                     <div class="item_nav">
  211.                         {% for ProductImage in Product.ProductImage %}
  212.                             <div class="slideThumb" data-index="{{ loop.index0 }}"><img src="{{ asset(ProductImage, 'save_image') }}"></div>
  213.                         {% endfor %}
  214.                     </div>
  215.                 </div>
  216.             </div>
  217.             <div class="ec-grid2__cell">
  218.                 <div class="ec-productRole__profile">
  219.                     {# 商品名 #}
  220.                     <div class="ec-productRole__title">
  221.                         <h2 class="ec-headingTitle">{{ Product.name }}</h2>
  222.                     </div>
  223.                     {# タグ #}
  224.                     <ul class="ec-productRole__tags">
  225.                         {% for Tag in Product.Tags %}
  226.                             <li class="ec-productRole__tag tag_{{ Tag.id }}">{{ Tag }}</li>
  227.                         {% endfor %}
  228.                     </ul>
  229.                     {# 通常価格 #}
  230.                     {% if Product.hasProductClass -%}
  231.                         <div class="ec-productRole__priceRegular">
  232.                             {% if Product.getPrice01Min is not null and Product.getPrice01IncTaxMin == Product.getPrice01IncTaxMax %}
  233.                                 <span class="ec-productRole__priceRegularPrice">{{ '通常価格'|trans }}:<span class="price01-default">{{ Product.getPrice01IncTaxMin|price }}</span></span>
  234.                                 <span class="ec-productRole__priceRegularTax">{{ '税込'|trans }}</span>
  235.                             {% elseif Product.getPrice01Min is not null and Product.getPrice01Max is not null %}
  236.                                 <span class="ec-productRole__priceRegularPrice">{{ '通常価格'|trans }}:<span class="price01-default">{{ Product.getPrice01IncTaxMin|price }}~ {{ Product.getPrice01IncTaxMax|price }}</span></span>
  237.                                 <span class="ec-productRole__priceRegularTax">{{ '税込'|trans }}</span>
  238.                             {% endif %}
  239.                         </div>
  240.                     {% else %}
  241.                         {% if Product.getPrice01Max is not null %}
  242.                             <span class="ec-productRole__priceRegularPrice">{{ '通常価格'|trans }}:{{ Product.getPrice01IncTaxMin|price }}</span>
  243.                             <span class="ec-productRole__priceRegularTax">{{ '税込'|trans }}</span>
  244.                         {% endif %}
  245.                     {% endif %}
  246.                     {# 販売価格 #}
  247.                     <div class="ec-productRole__price">
  248.                         {% if Product.hasProductClass -%}
  249.                             {% if Product.getPrice02IncTaxMin == Product.getPrice02IncTaxMax %}
  250.                                 <div class="ec-price">
  251.                                     <span class="ec-price__price price02-default">{{ Product.getPrice02IncTaxMin|price }}</span>
  252.                                     <span class="ec-price__tax">{{ '税込'|trans }}</span>
  253.                                 </div>
  254.                             {% else %}
  255.                                 <div class="ec-price">
  256.                                     <span class="ec-price__price price02-default">{{ Product.getPrice02IncTaxMin|price }} ~ {{ Product.getPrice02IncTaxMax|price }}</span>
  257.                                     <span class="ec-price__tax">{{ '税込'|trans }}</span>
  258.                                 </div>
  259.                             {% endif %}
  260.                         {% else %}
  261.                             <div class="ec-price">
  262.                                 <span class="ec-price__price">{{ Product.getPrice02IncTaxMin|price }}</span>
  263.                                 <span class="ec-price__tax">{{ '税込'|trans }}</span>
  264.                             </div>
  265.                         {% endif %}
  266.                     </div>
  267.                     {# 商品コード #}
  268.                     {% if Product.code_min is not empty %}
  269.                         <div class="ec-productRole__code">
  270.                             {{ '商品コード'|trans }}: <span class="product-code-default">{{ Product.code_min }}{% if Product.code_min != Product.code_max %} ~ {{ Product.code_max }}{% endif %}</span>
  271.                         </div>
  272.                     {% endif %}
  273.                     {# 関連カテゴリ
  274.                     {% if Product.ProductCategories is not empty %}
  275.                         <div class="ec-productRole__category">
  276.                             <div>{{ '関連カテゴリ'|trans }}</div>
  277.                             {% for ProductCategory in Product.ProductCategories %}
  278.                                 <ul>
  279.                                     <li>
  280.                                         {% for Category in ProductCategory.Category.path %}
  281.                                             <a href="{{ url('product_list') }}?category_id={{ Category.id }}">{{ Category.name }}</a> {%- if loop.last == false %}
  282.                                             <span>></span>{% endif -%}
  283.                                         {% endfor %}
  284.                                     </li>
  285.                                 </ul>
  286.                             {% endfor %}
  287.                         </div>
  288.                     {% endif %}#}
  289.                     <form action="{{ url('product_add_cart', {id:Product.id}) }}" method="post" id="form1" name="form1">
  290.                         {% if Product.stock_find %}
  291.                             <div class="ec-productRole__actions">
  292.                                 {% if form.classcategory_id1 is defined %}
  293.                                     <div class="ec-select">
  294.                                         {{ form_widget(form.classcategory_id1) }}
  295.                                         {{ form_errors(form.classcategory_id1) }}
  296.                                     </div>
  297.                                     {% if form.classcategory_id2 is defined %}
  298.                                         <div class="ec-select">
  299.                                             {{ form_widget(form.classcategory_id2) }}
  300.                                             {{ form_errors(form.classcategory_id2) }}
  301.                                         </div>
  302.                                     {% endif %}
  303.                                 {% endif %}
  304.                                 <div class="ec-numberInput"><span>{{ '数量'|trans }}</span>
  305.                                     {{ form_widget(form.quantity) }}
  306.                                     {{ form_errors(form.quantity) }}
  307.                                 </div>
  308.                             </div>
  309.                             <div class="ec-productRole__btn">
  310.                                 <button type="submit" class="ec-blockBtn--action add-cart">
  311.                                     {{ 'カートに入れる'|trans }}
  312.                                 </button>
  313.                             </div>
  314.                         {% else %}
  315.                             <div class="ec-productRole__btn">
  316.                                 <button type="button" class="ec-blockBtn--action" disabled="disabled">
  317.                                     {{ 'ただいま品切れ中です。'|trans }}
  318.                                 </button>
  319.                             </div>
  320.                         {% endif %}
  321.                         {{ form_rest(form) }}
  322.                     </form>
  323.                     <div class="ec-modal">
  324.                         <div class="ec-modal-overlay">
  325.                             <div class="ec-modal-wrap">
  326.                                 <span class="ec-modal-close"><span class="ec-icon"><img src="{{ asset('assets/icon/cross-dark.svg') }}" alt=""/></span></span>
  327.                                 <div id="ec-modal-header" class="text-center">{{ 'カートに追加しました。'|trans }}</div>
  328.                                 <div class="ec-modal-box">
  329.                                     <div class="ec-role">
  330.                                         <span class="ec-inlineBtn--cancel">{{ 'お買い物を続ける'|trans }}</span>
  331.                                         <a href="{{ url('cart') }}" class="ec-inlineBtn--action">{{ 'カートへ進む'|trans }}</a>
  332.                                     </div>
  333.                                 </div>
  334.                             </div>
  335.                         </div>
  336.                     </div>
  337.                     {% if BaseInfo.option_favorite_product %}
  338.                         <form action="{{ url('product_add_favorite', {id:Product.id}) }}" method="post">
  339.                             <div class="ec-productRole__btn">
  340.                                 {% if is_favorite == false %}
  341.                                     <button type="submit" id="favorite">
  342.                                         {{ 'お気に入りに追加'|trans }}
  343.                                     </button>
  344.                                 {% else %}
  345.                                     <button type="submit" id="favorite"
  346.                                             disabled="disabled">{{ 'お気に入りに追加済です。'|trans }}
  347.                                     </button>
  348.                                 {% endif %}
  349.                             </div>
  350.                         </form>
  351.                     {% endif %}
  352.                     <div class="ec-productRole__description">{{ Product.description_detail|raw|nl2br }}
  353.                     </div>
  354.                 </div>
  355.             </div>
  356.         </div>
  357.         {% if Product.freearea %}
  358.              <div class="ec-productRole__description">
  359.                  {{ include(template_from_string(Product.freearea)) }}
  360.             </div>
  361.         {% endif %}
  362.     </div>
  363. {% endblock %}