app/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 detailWrap' %}
  10. {% set breadcrumbs = {
  11.     '/products/list':'商品一覧',
  12.     '':Product.name
  13. } %}
  14. {% block javascript %}
  15.     <script>
  16.         eccube.classCategories = {{ class_categories_as_json(Product)|raw }};
  17.         // 規格2に選択肢を割り当てる。
  18.         function fnSetClassCategories(form, classcat_id2_selected) {
  19.             var $form = $(form);
  20.             var product_id = $form.find('input[name=product_id]').val();
  21.             var $sele1 = $form.find('select[name=classcategory_id1]');
  22.             var $sele2 = $form.find('select[name=classcategory_id2]');
  23.             eccube.setClassCategories($form, product_id, $sele1, $sele2, classcat_id2_selected);
  24.         }
  25.         {% if form.classcategory_id2 is defined %}
  26.         fnSetClassCategories(
  27.             $('#form1'), {{ form.classcategory_id2.vars.value|json_encode|raw }}
  28.         );
  29.         {% elseif form.classcategory_id1 is defined %}
  30.         eccube.checkStock($('#form1'), {{ Product.id }}, {{ form.classcategory_id1.vars.value|json_encode|raw }}, null);
  31.         {% endif %}
  32.     </script>
  33.     <script>
  34.         $(function() {
  35.             // bfcache無効化
  36.             $(window).bind('pageshow', function(event) {
  37.                 if (event.originalEvent.persisted) {
  38.                     location.reload(true);
  39.                 }
  40.             });
  41.             $('.item_visual').slick({
  42.                 dots: false,
  43.                 arrows: false,
  44.                 responsive: [{
  45.                     breakpoint: 768,
  46.                     settings: {
  47.                         dots: true
  48.                     }
  49.                 }]
  50.             });
  51.             $('.slideThumb').on('click', function() {
  52.                 var index = $(this).attr('data-index');
  53.                 $('.item_visual').slick('slickGoTo', index, false);
  54.             })
  55.         });
  56.     </script>
  57.     <script>
  58.         $(function() {
  59.             $('.add-cart').on('click', function(event) {
  60.                 var form_prefix = '.cartArea01 ';
  61.                 if($(this).hasClass('fixBox01-add-cart')){
  62.                     form_prefix = '.fixBox01 ';
  63.                 }else if($(this).hasClass('lpCartBtn')){
  64.                     form_prefix = '.lpCartArea01 '
  65.                 }
  66.                 {% if form.classcategory_id1 is defined %}
  67.                 console.log('c1');
  68.                 // 規格1フォームの必須チェック
  69.                 if ($(form_prefix + '#classcategory_id1').val() == '__unselected' || $(form_prefix + '#classcategory_id1').val() == '') {
  70.                     console.log('c2')
  71.                     $(form_prefix + '#classcategory_id1')[0].setCustomValidity('{{ '項目が選択されていません'|trans }}');
  72.                     return true;
  73.                 } else {
  74.                     $(form_prefix + '#classcategory_id1')[0].setCustomValidity('');
  75.                 }
  76.                 {% endif %}
  77.                 console.log('bbb');
  78.                 {% if form.classcategory_id2 is defined %}
  79.                 // 規格2フォームの必須チェック
  80.                 if ($(form_prefix + '#classcategory_id2').val() == '__unselected' || $(form_prefix + '#classcategory_id2').val() == '') {
  81.                     $(form_prefix + '#classcategory_id2')[0].setCustomValidity('{{ '項目が選択されていません'|trans }}');
  82.                     return true;
  83.                 } else {
  84.                     $(form_prefix + '#classcategory_id2')[0].setCustomValidity('');
  85.                 }
  86.                 {% endif %}
  87.                 console.log('ccccc');
  88.                 // 個数フォームのチェック
  89.                 if ($(form_prefix + '#quantity').val() < 1) {
  90.                     $(form_prefix + '#quantity')[0].setCustomValidity('{{ '1以上で入力してください。'|trans }}');
  91.                     return true;
  92.                 } else {
  93.                     $(form_prefix + '#quantity')[0].setCustomValidity('');
  94.                 }
  95.                 console.log('ddddd');
  96.                 event.preventDefault();
  97.                 $form = $(form_prefix + '#form1');
  98.                 $.ajax({
  99.                     url: $form.attr('action'),
  100.                     type: $form.attr('method'),
  101.                     data: $form.serialize(),
  102.                     dataType: 'json',
  103.                     beforeSend: function(xhr, settings) {
  104.                         // Buttonを無効にする
  105.                         $('.add-cart').prop('disabled', true);
  106.                     }
  107.                 }).done(function(data) {
  108.                     // レスポンス内のメッセージをalertで表示
  109.                     $.each(data.messages, function() {
  110.                         $('#ec-modal-header').html(this);
  111.                     });
  112.                     $('#ec-modal-checkbox').prop('checked', true);
  113.                     // カートブロックを更新する
  114.                     $.ajax({
  115.                         url: "{{ url('block_cart') }}",
  116.                         type: 'GET',
  117.                         dataType: 'html'
  118.                     }).done(function(html) {
  119.                         $('.ec-headerRole__cart').html(html);
  120.                     });
  121.                 }).fail(function(data) {
  122.                     alert('{{ 'カートへの追加に失敗しました。'|trans }}');
  123.                 }).always(function(data) {
  124.                     // Buttonを有効にする
  125.                     $('.add-cart').prop('disabled', false);
  126.                 });
  127.             });
  128.         });
  129.     </script>
  130. {% endblock %}
  131. {% block main %}
  132. {% include 'Block/breadcrumbs.twig' %}
  133. {% if Product.template_type is null %}
  134.     {% include 'Product/detail_default.twig' %}
  135. {% else %}
  136.     {% include Product.template_type %}
  137. {% endif %}
  138. <!-- カート追加後のモーダル -->
  139. <div class="ec-modal">
  140.     <input type="checkbox" id="ec-modal-checkbox" class="checkbox">
  141.     <div class="ec-modal-overlay">
  142.         <label for="ec-modal-checkbox" class="ec-modal-overlay-close"></label>
  143.         <div class="ec-modal-wrap">
  144.             <label for="ec-modal-checkbox" class="ec-modal-close"><span class="ec-icon"><img src="/html/user_data/dummy.jpg" class="lazy" data-src="/html/template/default/assets/icon/cross-dark.svg" alt=""/></span></label>
  145.             <div id="ec-modal-header" class="text-center">カートに追加しました。</div>
  146.             <div class="ec-modal-box">
  147.                 <div class="ec-role">
  148.                     <label for="ec-modal-checkbox" class="ec-inlineBtn--cancel">お買い物を続ける</label>
  149.                     <a href="/cart" class="ec-inlineBtn--action">カートへ進む</a>
  150.                 </div>
  151.             </div>
  152.         </div>
  153.     </div>
  154. </div>
  155. <!-- 下部固定カート追加ボタン -->
  156. <div class="fixBox01">
  157.     <div class="flexWrap">
  158.         <form action="{{ url('product_add_cart', {id:Product.id}) }}" method="post" id="form1" name="form1">
  159.         {% if Product.cart_btn_type == "1" %}
  160.         <div class="telBox pc">
  161.             <span class="telTxt">
  162.                 <img src="/html/user_data/dummy.jpg" class="lazy" data-src="/html/template/default/assets/img/common/ico_tel_pink.png" alt="">
  163.                 {{ BaseInfo.getTelNumber }}
  164.                 <span>[受付時間]平日 10:00~18:00</span>
  165.             </span>
  166.         </div>
  167.             <p class="sp txt">この商品ついて<span>申込み・問合せ</span>する</p>
  168.         <div class="btnBox spWidth01">
  169.             <a href="tel:{{ BaseInfo.TelNumber }}" class="btn02 sp tel lineBtn01"><img src="/html/user_data/dummy.jpg" class="lazy" data-src="/html/template/default/assets/img/common/ico_tel_pink.png" alt="">電話をかける</span><img src="/html/user_data/dummy.jpg" class="lazy" data-src="/html/user_data/assets/img/top/ico_bottom01.png" alt=""></a>
  170.             <a href="/contact" class="btn02 mailBtn01"><img src="/html/user_data/dummy.jpg" class="lazy" data-src="/html/user_data/assets/img/top/ico_mail01.png" alt="">メール<span class="pc">で<br>申込み・問合せする</span><img src="/html/user_data/dummy.jpg" class="lazy" data-src="/html/user_data/assets/img/top/ico_arrow_right01.png" alt=""></a>
  171.         </div>
  172.         {% else %}
  173.         <div class="priceWrap">
  174.             {% if Product.ProductClasses.0.SaleType.id == 3 %}
  175.                 <p class="rentalPrice lowPrice">
  176.                     <span class="priceTxt"> <span class="tag06">初月費用</span>{{ (Product.getPrice02IncTaxMin)|price }}<span class="label">税込</span></span><br>
  177.                     <span class="priceTxt"> <span class="tag06 white">2ヶ月目以降</span>{{ (Product.ProductClasses.0.getSlnRegularPrice2 * 1.1)|price }}<span class="label">税込/月</span></span>
  178.                 </p>
  179.             {% else %}
  180.             <p class="lowPrice">
  181.                 {% if Product.hasProductClass -%}
  182.                     {% if Product.getPrice01Min is not null and Product.getPrice01IncTaxMin == Product.getPrice01IncTaxMax %}
  183.                         <span class="priceTxt">{{ (Product.getPrice01IncTaxMin)|price }} <span class="label">税込</span></span>
  184.                     {% elseif Product.getPrice01Min is not null and Product.getPrice01Max is not null %}
  185.                             <span class="priceTxt">{{ Product.getPrice01IncTaxMin|price }}~ {{ Product.getPrice01IncTaxMax|price }} <span class="label">税込</span></span>
  186.                     {% elseif Product.getPrice02Min is not null and Product.getPrice02IncTaxMin == Product.getPrice02IncTaxMax %}
  187.                         <span class="priceTxt">{{ (Product.getPrice02IncTaxMin)|price }} <span class="label">税込</span></span>
  188.                     {% elseif Product.getPrice02Min is not null and Product.getPrice02Max is not null %}
  189.                             <span class="priceTxt">{{ Product.getPrice02IncTaxMin|price }}~ {{ Product.getPrice02IncTaxMax|price }} <span class="label">税込</span></span>
  190.                     {% endif %}
  191.                 {% else %}
  192.                         <span class="priceTxt">{{ Product.getPrice02IncTaxMin|price }} <span class="label">税込</span></span>
  193.                 {% endif %}
  194.             {% endif %}
  195.             </p>
  196.         </div>
  197.         <div class="optionsWrap">
  198.             {% if Product.stock_find %}
  199.                 <div class="ec-productRole__actions">
  200.                     {% if form1.classcategory_id1 is defined %}
  201.                     <div class="txt">
  202.                          <img src="/html/user_data/dummy.jpg" class="lazy" data-src="/html/template/default/assets/img/common/item_select_icon.png" alt="">
  203.                     </div>
  204.                     <div class="classList">
  205.                         <div class="ec-select {% if form1.classcategory_id2 is defined %}half{% endif %}">
  206.                             <span>{{ Product.getClassName1 }}</span>
  207.                             {{ form_widget(form1.classcategory_id1) }}
  208.                             {{ form_errors(form1.classcategory_id1) }}
  209.                         </div>
  210.                         {% if form1.classcategory_id2 is defined %}
  211.                             <div class="ec-select half">
  212.                                 <span>{{ Product.getClassName2 }}</span>
  213.                                 {{ form_widget(form1.classcategory_id2) }}
  214.                                 {{ form_errors(form1.classcategory_id2) }}
  215.                             </div>
  216.                         {% endif %}
  217.                     </div>
  218.                     {% endif %}
  219.                 </div>
  220.             {% else %}
  221.                 <div class="ec-productRole__btn">
  222.                     <button type="button" class="ec-blockBtn--action" disabled="disabled">
  223.                         {{ 'ただいま品切れ中です。'|trans }}
  224.                     </button>
  225.                 </div>
  226.             {% endif %}
  227.         </div>
  228.         <div class="cartWrap">
  229.             <div class="ec-numberInput">
  230.                 <span>{{ '数量'|trans }}</span>
  231.                 {{ form_widget(form1.quantity) }}
  232.                 {{ form_errors(form1.quantity) }}
  233.             </div>
  234.             <div class="spTrigger sp {% if Product.hasProductClass == false -%}hide{% endif %}"><img src="/html/user_data/dummy.jpg" class="lazy" data-src="/html/user_data/assets/img/top/ico_arrow_right01.png" alt=""></div>
  235.             <div class="ec-productRole__btn">
  236.                     <button type="submit" class="ec-blockBtn--action add-cart fixBox01-add-cart btn-primary btnType01 {% if Product.hasProductClass == false -%}btnTxtCenter{% endif %}">カートに追加</button>
  237.             </div>
  238.             {{ form_rest(form1) }}
  239.         </div>
  240.         {% endif %}
  241.         </form>
  242.     </div>
  243. </div>
  244. {% endblock %}