app/template/originalTemplate/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.             $('.slideThumb').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-overlay, .ec-modal .ec-inlineBtn--cancel').on('click', function() {
  182.             $('.ec-modal').hide()
  183.         });
  184.     </script>
  185. {% endblock %}
  186. {% block main %}
  187.     <div class="ec-productRole">
  188.         <div class="ec-grid2">
  189.             <div class="ec-grid2__cell">
  190.                 <div class="ec-sliderItemRole">
  191.                     <div class="item_visual">
  192.                         {% for ProductImage in Product.ProductImage %}
  193.                             <div class="slide-item"><img src="{{ asset(ProductImage, 'save_image') }}"></div>
  194.                         {% else %}
  195.                             <div class="slide-item"><img src="{{ asset(''|no_image_product, 'save_image') }}"/></div>
  196.                         {% endfor %}
  197.                     </div>
  198.                     <div class="item_nav">
  199.                         {% for ProductImage in Product.ProductImage %}
  200.                             <div class="slideThumb" data-index="{{ loop.index0 }}"><img src="{{ asset(ProductImage, 'save_image') }}"></div>
  201.                         {% endfor %}
  202.                     </div>
  203.                 </div>
  204.             </div>
  205.             <div class="ec-grid2__cell">
  206.                 <div class="ec-productRole__profile">
  207.                     {# 商品名 #}
  208.                     <div class="ec-productRole__title">
  209.                         <h2 class="ec-headingTitle">{{ Product.name }}</h2>
  210.                     </div>
  211.                     {# タグ #}
  212.                     <ul class="ec-productRole__tags">
  213.                         {% for Tag in Product.Tags %}
  214.                             <li class="ec-productRole__tag tag_{{ Tag.id }}">{{ Tag }}</li>
  215.                         {% endfor %}
  216.                     </ul>
  217.                     {# 通常価格 #}
  218.                     {% if Product.hasProductClass -%}
  219.                         <div class="ec-productRole__priceRegular">
  220.                             {% if Product.getPrice01Min is not null and Product.getPrice01IncTaxMin == Product.getPrice01IncTaxMax %}
  221.                                 <span class="ec-productRole__priceRegularPrice">{{ '通常価格'|trans }}:<span class="price01-default">{{ Product.getPrice01IncTaxMin|price }}</span></span>
  222.                                 <span class="ec-productRole__priceRegularTax">{{ '税込'|trans }}</span>
  223.                             {% elseif Product.getPrice01Min is not null and Product.getPrice01Max is not null %}
  224.                                 <span class="ec-productRole__priceRegularPrice">{{ '通常価格'|trans }}:<span class="price01-default">{{ Product.getPrice01IncTaxMin|price }}~ {{ Product.getPrice01IncTaxMax|price }}</span></span>
  225.                                 <span class="ec-productRole__priceRegularTax">{{ '税込'|trans }}</span>
  226.                             {% endif %}
  227.                         </div>
  228.                     {% else %}
  229.                         {% if Product.getPrice01Max is not null %}
  230.                             <span class="ec-productRole__priceRegularPrice">{{ '通常価格'|trans }}:{{ Product.getPrice01IncTaxMin|price }}</span>
  231.                             <span class="ec-productRole__priceRegularTax">{{ '税込'|trans }}</span>
  232.                         {% endif %}
  233.                     {% endif %}
  234.                     {# 販売価格 #}
  235.                     <div class="ec-productRole__price">
  236.                         {% if Product.hasProductClass -%}
  237.                             {% if Product.getPrice02IncTaxMin == Product.getPrice02IncTaxMax %}
  238.                                 <div class="ec-price">
  239.                                     <span class="ec-price__price price02-default">{{ Product.getPrice02IncTaxMin|price }}</span>
  240.                                     <span class="ec-price__tax">{{ '税込'|trans }}</span>
  241.                                 </div>
  242.                             {% else %}
  243.                                 <div class="ec-price">
  244.                                     <span class="ec-price__price price02-default">{{ Product.getPrice02IncTaxMin|price }} ~ {{ Product.getPrice02IncTaxMax|price }}</span>
  245.                                     <span class="ec-price__tax">{{ '税込'|trans }}</span>
  246.                                 </div>
  247.                             {% endif %}
  248.                         {% else %}
  249.                             <div class="ec-price">
  250.                                 <span class="ec-price__price">{{ Product.getPrice02IncTaxMin|price }}</span>
  251.                                 <span class="ec-price__tax">{{ '税込'|trans }}</span>
  252.                             </div>
  253.                         {% endif %}
  254.                     </div>
  255.                     {# 商品コード #}
  256.                     {% if Product.code_min is not empty %}
  257.                         <div class="ec-productRole__code">
  258.                             {{ '商品コード'|trans }}: <span class="product-code-default">{{ Product.code_min }}{% if Product.code_min != Product.code_max %} ~ {{ Product.code_max }}{% endif %}</span>
  259.                         </div>
  260.                     {% endif %}
  261.                     {# 関連カテゴリ #}
  262.                     {% if Product.ProductCategories is not empty %}
  263.                         <div class="ec-productRole__category">
  264.                             <div>{{ '関連カテゴリ'|trans }}</div>
  265.                             {% for ProductCategory in Product.ProductCategories %}
  266.                                 <ul>
  267.                                     <li>
  268.                                         {% for Category in ProductCategory.Category.path %}
  269.                                             <a href="{{ url('product_list') }}?category_id={{ Category.id }}">{{ Category.name }}</a> {%- if loop.last == false %}
  270.                                             <span>></span>{% endif -%}
  271.                                         {% endfor %}
  272.                                     </li>
  273.                                 </ul>
  274.                             {% endfor %}
  275.                         </div>
  276.                     {% endif %}
  277.                     <form action="{{ url('product_add_cart', {id:Product.id}) }}" method="post" id="form1" name="form1">
  278.                         {% if Product.stock_find %}
  279.                             <div class="ec-productRole__actions">
  280.                                 {% if form.classcategory_id1 is defined %}
  281.                                     <div class="ec-select">
  282.                                         {{ form_widget(form.classcategory_id1) }}
  283.                                         {{ form_errors(form.classcategory_id1) }}
  284.                                     </div>
  285.                                     {% if form.classcategory_id2 is defined %}
  286.                                         <div class="ec-select">
  287.                                             {{ form_widget(form.classcategory_id2) }}
  288.                                             {{ form_errors(form.classcategory_id2) }}
  289.                                         </div>
  290.                                     {% endif %}
  291.                                 {% endif %}
  292.                                 <div class="ec-numberInput"><span>{{ '数量'|trans }}</span>
  293.                                     {{ form_widget(form.quantity) }}
  294.                                     {{ form_errors(form.quantity) }}
  295.                                 </div>
  296.                             </div>
  297.                             <div class="ec-productRole__btn">
  298.                                 <button type="submit" class="ec-blockBtn--action add-cart">
  299.                                     {{ 'カートに入れる'|trans }}
  300.                                 </button>
  301.                             </div>
  302.                         {% else %}
  303.                             <div class="ec-productRole__btn">
  304.                                 <button type="button" class="ec-blockBtn--action" disabled="disabled">
  305.                                     {{ 'ただいま品切れ中です。'|trans }}
  306.                                 </button>
  307.                             </div>
  308.                         {% endif %}
  309.                         {{ form_rest(form) }}
  310.                     </form>
  311.                     <div class="ec-modal">
  312.                         <div class="ec-modal-overlay">
  313.                             <div class="ec-modal-wrap">
  314.                                 <span class="ec-modal-close"><span class="ec-icon"><img src="{{ asset('assets/icon/cross-dark.svg') }}" alt=""/></span></span>
  315.                                 <div id="ec-modal-header" class="text-center">{{ 'カートに追加しました。'|trans }}</div>
  316.                                 <div class="ec-modal-box">
  317.                                     <div class="ec-role">
  318.                                         <span class="ec-inlineBtn--cancel">{{ 'お買い物を続ける'|trans }}</span>
  319.                                         <a href="{{ url('cart') }}" class="ec-inlineBtn--action">{{ 'カートへ進む'|trans }}</a>
  320.                                     </div>
  321.                                 </div>
  322.                             </div>
  323.                         </div>
  324.                     </div>
  325.                     {% if BaseInfo.option_favorite_product %}
  326.                         <form action="{{ url('product_add_favorite', {id:Product.id}) }}" method="post">
  327.                             <div class="ec-productRole__btn">
  328.                                 {% if is_favorite == false %}
  329.                                     <button type="submit" id="favorite" class="ec-blockBtn--cancel">
  330.                                         {{ 'お気に入りに追加'|trans }}
  331.                                     </button>
  332.                                 {% else %}
  333.                                     <button type="submit" id="favorite" class="ec-blockBtn--cancel"
  334.                                             disabled="disabled">{{ 'お気に入りに追加済です。'|trans }}
  335.                                     </button>
  336.                                 {% endif %}
  337.                             </div>
  338.                         </form>
  339.                     {% endif %}
  340.                     <div class="ec-productRole__description">{{ Product.description_detail|raw|nl2br }}
  341.                     </div>
  342.                 </div>
  343.             </div>
  344.         </div>
  345.         {% if Product.freearea %}
  346.              <div class="ec-productRole__description">
  347.                  {{ include(template_from_string(Product.freearea)) }}
  348.             </div>
  349.         {% endif %}
  350.     </div>
  351. {% endblock %}