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

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