app/template/anivbtob/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.         /*設定価格*/
  76.         .Biz_Pricing{
  77.         line-height:1;
  78.         font-size:16px;
  79.         padding-left:1em;
  80.         }
  81.         .Biz_Pricing_price{
  82.         font-size:14px;
  83.         padding:8px 16px;
  84.         border-radius:4px;
  85.         /* border:1px solid #333; */
  86.         background-color: rgb(244, 238, 222);
  87.         }
  88.         /*価格*/
  89.         .Biz_ec-price__price{
  90.         font-size:14px;
  91.         line-height:1;
  92.         padding:8px 16px;
  93.         border-radius:4px;
  94.         border:1px solid #282828;
  95.         vertical-align: middle;
  96.         /* background-color: rgb(244, 238, 222);*/
  97.         }
  98.         /*フリーエリア寸法表*/
  99.         .size_dimension{}
  100.         .size_dimension__Title{
  101.         text-algn:center;
  102.         font-size:1.4rem;
  103.         margin:1em auto;
  104.         }
  105.         .size_dimension table {
  106.         background-color: #fff;
  107.         border-collapse: collapse;
  108.         width:  100%;
  109.         white-space: nowrap; */
  110.         table-layout: fixed;
  111.         min-width: 460px;
  112.         }
  113.         .size_dimension th {
  114.         background-color: rgb(244, 238, 222);
  115.         }
  116.         .size_dimension th,.size_dimension td {
  117.         border: solid 1px #ececec;
  118.         padding: 5px 10px;
  119.         text-align:center;
  120.         }
  121.         .table-wrap {
  122.         overflow-x: scroll;
  123.         }
  124.     </style>
  125. {% endblock %}
  126. {% block javascript %}
  127.     <script>
  128.         eccube.classCategories = {{ class_categories_as_json(Product)|raw }};
  129.         // 規格2に選択肢を割り当てる。
  130.         function fnSetClassCategories(form, classcat_id2_selected) {
  131.             var $form = $(form);
  132.             var product_id = $form.find('input[name=product_id]').val();
  133.             var $sele1 = $form.find('select[name=classcategory_id1]');
  134.             var $sele2 = $form.find('select[name=classcategory_id2]');
  135.             eccube.setClassCategories($form, product_id, $sele1, $sele2, classcat_id2_selected);
  136.         }
  137.         {% if form.classcategory_id2 is defined %}
  138.         fnSetClassCategories(
  139.             $('#form1'), {{ form.classcategory_id2.vars.value|json_encode|raw }}
  140.         );
  141.         {% elseif form.classcategory_id1 is defined %}
  142.         eccube.checkStock($('#form1'), {{ Product.id }}, {{ form.classcategory_id1.vars.value|json_encode|raw }}, null);
  143.         {% endif %}
  144.     </script>
  145.     <script>
  146.         $(function() {
  147.             // bfcache無効化
  148.             $(window).bind('pageshow', function(event) {
  149.                 if (event.originalEvent.persisted) {
  150.                     location.reload(true);
  151.                 }
  152.             });
  153.             // Core Web Vital の Cumulative Layout Shift(CLS)対策のため
  154.             // img タグに width, height が付与されている.
  155.             // 630px 未満の画面サイズでは縦横比が壊れるための対策
  156.             // see https://github.com/EC-CUBE/ec-cube/pull/5023
  157.             $('.ec-grid2__cell').hide();
  158.             var removeSize = function () {
  159.                 $('.slide-item').height('');
  160.                 $('.slide-item img')
  161.                     .removeAttr('width')
  162.                     .removeAttr('height')
  163.                     .removeAttr('style');
  164.             };
  165.             var slickInitial = function(slick) {
  166.                 $('.ec-grid2__cell').fadeIn(1500);
  167.                 var baseHeight = $(slick.target).height();
  168.                 var baseWidth = $(slick.target).width();
  169.                 var rate = baseWidth / baseHeight;
  170.                 $('.slide-item').height(baseHeight * rate); // 余白を削除する
  171.                 // transform を使用することでCLSの影響を受けないようにする
  172.                 $('.slide-item img')
  173.                     .css(
  174.                         {
  175.                             'transform-origin': 'top left',
  176.                             'transform': 'scaleY(' + rate + ')',
  177.                             'transition': 'transform .1s'
  178.                         }
  179.                     );
  180.                 // 正しいサイズに近くなったら属性を解除する
  181.                 setTimeout(removeSize, 500);
  182.             };
  183.             $('.item_visual').on('init', slickInitial);
  184.             // リサイズ時は CLS の影響を受けないため属性を解除する
  185.             $(window).resize(removeSize);
  186.             $('.item_visual').slick({
  187.                 dots: false,
  188.                 arrows: false,
  189.                 responsive: [{
  190.                     breakpoint: 768,
  191.                     settings: {
  192.                         dots: true
  193.                     }
  194.                 }]
  195.             });
  196.             $('.slideThumb').on('click', function() {
  197.                 var index = $(this).attr('data-index');
  198.                 $('.item_visual').slick('slickGoTo', index, false);
  199.             })
  200.         });
  201.     </script>
  202.     <script>
  203.         $(function() {
  204.             $('.add-cart').on('click', function(event) {
  205.                 {% if form.classcategory_id1 is defined %}
  206.                 // 規格1フォームの必須チェック
  207.                 if ($('#classcategory_id1').val() == '__unselected' || $('#classcategory_id1').val() == '') {
  208.                     $('#classcategory_id1')[0].setCustomValidity('{{ '項目が選択されていません'|trans }}');
  209.                     return true;
  210.                 } else {
  211.                     $('#classcategory_id1')[0].setCustomValidity('');
  212.                 }
  213.                 {% endif %}
  214.                 {% if form.classcategory_id2 is defined %}
  215.                 // 規格2フォームの必須チェック
  216.                 if ($('#classcategory_id2').val() == '__unselected' || $('#classcategory_id2').val() == '') {
  217.                     $('#classcategory_id2')[0].setCustomValidity('{{ '項目が選択されていません'|trans }}');
  218.                     return true;
  219.                 } else {
  220.                     $('#classcategory_id2')[0].setCustomValidity('');
  221.                 }
  222.                 {% endif %}
  223.                 // 個数フォームのチェック
  224.                 if ($('#quantity').val() < 1) {
  225.                     $('#quantity')[0].setCustomValidity('{{ '1以上で入力してください。'|trans }}');
  226.                     return true;
  227.                 } else {
  228.                     $('#quantity')[0].setCustomValidity('');
  229.                 }
  230.                 event.preventDefault();
  231.                 $form = $('#form1');
  232.                 $.ajax({
  233.                     url: $form.attr('action'),
  234.                     type: $form.attr('method'),
  235.                     data: $form.serialize(),
  236.                     dataType: 'json',
  237.                     beforeSend: function(xhr, settings) {
  238.                         // Buttonを無効にする
  239.                         $('.add-cart').prop('disabled', true);
  240.                     }
  241.                 }).done(function(data) {
  242.                     // レスポンス内のメッセージをalertで表示
  243.                     $.each(data.messages, function() {
  244.                         $('#ec-modal-header').text(this);
  245.                     });
  246.                     $('.ec-modal').show()
  247.                     // カートブロックを更新する
  248.                     $.ajax({
  249.                         url: "{{ url('block_cart') }}",
  250.                         type: 'GET',
  251.                         dataType: 'html'
  252.                     }).done(function(html) {
  253.                         $('.ec-headerRole__cart').html(html);
  254.                     });
  255.                 }).fail(function(data) {
  256.                     alert('{{ 'カートへの追加に失敗しました。'|trans }}');
  257.                 }).always(function(data) {
  258.                     // Buttonを有効にする
  259.                     $('.add-cart').prop('disabled', false);
  260.                 });
  261.             });
  262.         });
  263.         $('.ec-modal-wrap').on('click', function(e) {
  264.             // モーダル内の処理は外側にバブリングさせない
  265.             e.stopPropagation();
  266.         });
  267.         $('.ec-modal-overlay, .ec-modal, .ec-modal-close, .ec-inlineBtn--cancel').on('click', function() {
  268.             $('.ec-modal').hide()
  269.         });
  270.     </script>
  271.     <script type="application/ld+json">
  272.     {
  273.         "@context": "https://schema.org/",
  274.         "@type": "Product",
  275.         "name": "{{ Product.name }}",
  276.         "image": [
  277.             {% for img in Product.ProductImage %}
  278.                 "{{ app.request.schemeAndHttpHost }}{{ asset(img, 'save_image') }}"{% if not loop.last %},{% endif %}
  279.             {% else %}
  280.                 "{{ app.request.schemeAndHttpHost }}{{ asset(''|no_image_product, 'save_image') }}"
  281.             {% endfor %}
  282.         ],
  283.         "description": "{{ Product.description_list | default(Product.description_detail) | replace({'\n': '', '\r': ''}) | slice(0,300) }}",
  284.         {% if Product.code_min %}
  285.         "sku": "{{ Product.code_min }}",
  286.         {% endif %}
  287.         "offers": {
  288.             "@type": "Offer",
  289.             "url": "{{ url('product_detail', {'id': Product.id}) }}",
  290.             "priceCurrency": "{{ eccube_config.currency }}",
  291.             "price": {{ Product.getPrice02IncTaxMin ? Product.getPrice02IncTaxMin : 0}},
  292.             "availability": "{{ Product.stock_find ? "InStock" : "OutOfStock" }}"
  293.         }
  294.     }
  295.     </script>
  296. {% endblock %}
  297. {% block main %}
  298.     <div class="ec-productRole">
  299.         <div class="ec-grid2">
  300.             <div class="ec-grid2__cell">
  301.                 <div class="ec-sliderItemRole">
  302.                     <div class="item_visual">
  303.                         {% for ProductImage in Product.ProductImage %}
  304.                             <div class="slide-item"><img src="{{ asset(ProductImage, 'save_image') }}" alt="{{ loop.first ? Product.name : '' }}" width="550" height="550"{% if loop.index > 1 %} loading="lazy"{% endif %}></div>
  305.                         {% else %}
  306.                             <div class="slide-item"><img src="{{ asset(''|no_image_product, 'save_image') }}" alt="{{ loop.first ? Product.name : '' }}" width="550" height="550"></div>
  307.                         {% endfor %}
  308.                     </div>
  309.                     <div class="item_nav">
  310.                         {% for ProductImage in Product.ProductImage %}
  311.                             <div class="slideThumb" data-index="{{ loop.index0 }}"><img src="{{ asset(ProductImage, 'save_image') }}" alt="" width="133" height="133" loading="lazy"></div>
  312.                         {% endfor %}
  313.                     </div>
  314.                 </div>
  315.             </div>
  316.             <div class="ec-grid2__cell">
  317.                 <div class="ec-productRole__profile">
  318.                  {# 商品コード #}
  319.                     {% if Product.code_min is not empty %}
  320.                         <div class="ec-productRole__code" style = "font-size:80%;padding-top:.2em;">
  321.                             {{ '商品コード'|trans }}: <span class="product-code-default">{{ Product.code_min }}{% if Product.code_min != Product.code_max %} ~ {{ Product.code_max }}{% endif %}</span>
  322.                         </div>
  323.                     {% endif %}
  324.                     {# 関連カテゴリ #}
  325.                     {# {% if Product.ProductCategories is not empty %}
  326.                         <div class="ec-productRole__category">
  327.                             <div>{{ '関連カテゴリ'|trans }}</div>
  328.                             {% for ProductCategory in Product.ProductCategories %}
  329.                                 <ul>
  330.                                     <li>
  331.                                         {% for Category in ProductCategory.Category.path %}
  332.                                             <a href="{{ url('product_list') }}?category_id={{ Category.id }}">{{ Category.name }}</a> {%- if loop.last == false %}
  333.                                             <span>></span>{% endif -%}
  334.                                         {% endfor %}
  335.                                     </li>
  336.                                 </ul>
  337.                             {% endfor %}
  338.                         </div>
  339.                     {% endif %} #}
  340.                     {# 関連カテゴリ カスタム#}
  341.                     {% if Product.ProductCategories is not empty %}
  342.                         <div style = "font-size:80%; style = "border:0;" class="ec-productRole__category">
  343.                             {% for ProductCategory in Product.ProductCategories %}
  344.                                 {% if (ProductCategory.Category.Children.snapshot == null) %}
  345.                                     <ol style = "list-style: none;margin:0;padding:0.4em;;">
  346.                                         <li style = "list-style: none;margin:0;padding:0;" class="breadcrumb-item">
  347.                                             {% for Category in ProductCategory.Category.path %}
  348.                                                 <a href="{{ url('product_list') }}?category_id={{ Category.id }}" class="text-secondary">{{ Category.name }}</a> {%- if loop.last == false %}
  349.                                                 <span>/</span>{% endif -%}
  350.                                             {% endfor %}
  351.                                         </li>
  352.                                     </ol>
  353.                                 {% endif %}
  354.                             {% endfor %}
  355.                         </div>
  356.                     {% endif %}
  357.                     {# タグ #}
  358.                     <ul class="ec-productRole__tags">
  359.                         {% for Tag in Product.Tags %}
  360.                             <li class="ec-productRole__tag tag_{{ Tag.id }}">{{ Tag }}</li>
  361.                         {% endfor %}
  362.                     </ul>
  363.                     {# 商品名 #}
  364.                     <div class="ec-productRole__title" style = "border:0;">
  365.                         <h2 class="ec-headingTitle" style = "border:0;">{{ Product.name }}</h2>
  366.                     </div>
  367.                     {# 商品説明#}
  368.                     <div class="ec-productRole__description" style = "margin-top:1em;">{{ Product.description_detail|raw|nl2br }}
  369.                     </div>
  370.                     {# 通常価格 #}
  371.                     {% if Product.hasProductClass -%}
  372.                         <div class="ec-productRole__priceRegular">
  373.                             {% if Product.getPrice01Min is not null and Product.getPrice01IncTaxMin == Product.getPrice01IncTaxMax %}
  374.                                 <span class="ec-productRole__priceRegularPrice">{{ '通常価格'|trans }}:<span class="price01-default">{{ Product.getPrice01IncTaxMin|price }}</span></span>
  375.                                 <span class="ec-productRole__priceRegularTax">{{ '税込'|trans }}</span>
  376.                             {% elseif Product.getPrice01Min is not null and Product.getPrice01Max is not null %}
  377.                                 <span class="ec-productRole__priceRegularPrice">{{ '通常価格'|trans }}:<span class="price01-default">{{ Product.getPrice01IncTaxMin|price }}~ {{ Product.getPrice01IncTaxMax|price }}</span></span>
  378.                                 <span class="ec-productRole__priceRegularTax">{{ '税込'|trans }}</span>
  379.                             {% endif %}
  380.                         </div>
  381.                     {% else %}
  382.                         {% if Product.getPrice01Max is not null %}
  383.                             <span class="ec-productRole__priceRegularPrice">{{ '通常価格'|trans }}:{{ Product.getPrice01IncTaxMin|price }}</span>
  384.                             <span class="ec-productRole__priceRegularTax">{{ '税込'|trans }}</span>
  385.                         {% endif %}
  386.                     {% endif %}
  387.                     {# 販売価格 #}
  388.                     <div class="ec-productRole__price" style = "padding-bottom:2em;">
  389.                         {% if Product.hasProductClass -%}
  390.                             {% if Product.getPrice02IncTaxMin == Product.getPrice02IncTaxMax %}
  391.                                 <div class="ec-price">
  392.                                     <span class="ec-price__price price02-default">{{ Product.getPrice02IncTaxMin|price }}</span>
  393.                                     <span class="ec-price__tax">{{ '税込'|trans }}</span>
  394.                                 </div>
  395.                             {% else %}
  396.                                 <div class="ec-price">
  397.                                     <span class="ec-price__price price02-default">{{ Product.getPrice02IncTaxMin|price }} ~ {{ Product.getPrice02IncTaxMax|price }}</span>
  398.                                     <span class="ec-price__tax">{{ '税込'|trans }}</span>
  399.                                 </div>
  400.                             {% endif %}
  401.                         {% else %}
  402.                             <div class="ec-price" style = "color:#3c3c44;">
  403.                                 <span class="ec-price__price" style = "padding-left:0;"><small class = "Biz_ec-price__price">リース料金</small>{{ Product.getPrice02IncTaxMin|price }}</span>
  404.                                 <span class="ec-price__tax" style = "margin-left:-1em;">{{ '(税込)'|trans }}</span>
  405.                             </div>
  406.                         {% endif %}
  407.                     </div>
  408.                     {# カート追加 #}
  409.                     <form action="{{ url('product_add_cart', {id:Product.id}) }}" method="post" id="form1" name="form1">
  410.                         {% if Product.stock_find %}
  411.                             <div class="ec-productRole__actions">
  412.                                 {% if form.classcategory_id1 is defined %}
  413.                                     <div class="ec-select">
  414.                                         {{ form_row(form.classcategory_id1) }}
  415.                                         {{ form_errors(form.classcategory_id1) }}
  416.                                     </div>
  417.                                     {% if form.classcategory_id2 is defined %}
  418.                                         <div class="ec-select">
  419.                                             {{ form_row(form.classcategory_id2) }}
  420.                                             {{ form_errors(form.classcategory_id2) }}
  421.                                         </div>
  422.                                     {% endif %}
  423.                                 {% endif %}
  424.                                 {# 数量フォームを非表示▼ #}
  425.                                 <div style="display:none;!important" class="ec-numberInput"><span>{{ '数量'|trans }}</span>
  426.                                     {{ form_widget(form.quantity) }}
  427.                                     {{ form_errors(form.quantity) }}
  428.                                 </div>
  429.                                 {# 数量フォームを非表示▲ #}
  430.                             </div>
  431.                             <div class="ec-productRole__btn">
  432.                                 <button type="submit" class="ec-blockBtn--action add-cart">
  433.                                     {{ 'カートに入れる'|trans }}
  434.                                 </button>
  435.                             </div>
  436.                         {% else %}
  437.                             <div class="ec-productRole__btn">
  438.                                 <button type="button" style = "color:#333;background:#fff;border:1px solid #ccc;" class="ec-blockBtn--action" disabled="disabled">
  439.                                     {{ 'ただいま品切れ中です。'|trans }}
  440.                                 </button>
  441.                             </div>
  442.                         {% endif %}
  443.                         {{ form_rest(form) }}
  444.                     </form>
  445.                     <div class="ec-modal">
  446.                         <div class="ec-modal-overlay">
  447.                             <div class="ec-modal-wrap">
  448.                                 <span class="ec-modal-close"><span class="ec-icon"><img src="{{ asset('assets/icon/cross-dark.svg') }}" alt=""/></span></span>
  449.                                 <div id="ec-modal-header" class="text-center">{{ 'カートに追加しました。'|trans }}</div>
  450.                                 <div class="ec-modal-box">
  451.                                     <div class="ec-role">
  452.                                         <span class="ec-inlineBtn--cancel">{{ 'お買い物を続ける'|trans }}</span>
  453.                                         <a href="{{ url('cart') }}" class="ec-inlineBtn--action">{{ 'カートへ進む'|trans }}</a>
  454.                                     </div>
  455.                                 </div>
  456.                             </div>
  457.                         </div>
  458.                     </div>
  459.                     {% if BaseInfo.option_favorite_product %}
  460.                         <form action="{{ url('product_add_favorite', {id:Product.id}) }}" method="post">
  461.                             <div class="ec-productRole__btn">
  462.                                 {% if is_favorite == false %}
  463.                                     <button type="submit" id="favorite" class="ec-blockBtn--cancel">
  464.                                         {{ 'お気に入りに追加'|trans }}
  465.                                     </button>
  466.                                 {% else %}
  467.                                     <button type="submit" id="favorite" class="ec-blockBtn--cancel"
  468.                                             disabled="disabled">{{ 'お気に入りに追加済です。'|trans }}
  469.                                     </button>
  470.                                 {% endif %}
  471.                             </div>
  472.                         </form>
  473.                     {% endif %}
  474.                     {# <div class="ec-productRole__description">{{ Product.description_detail|raw|nl2br }}
  475.                     </div> #}
  476.                 </div>
  477.             </div>
  478.         </div>
  479.         {% if Product.freearea %}
  480.              <div class="ec-productRole__description">
  481.                  {{ include(template_from_string(Product.freearea)) }}
  482.             </div>
  483.         {% endif %}
  484.     </div>
  485. {% endblock %}