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

Open in your IDE?
  1. {#
  2. This file is part of EC-CUBE
  3. Copyright(c) LOCKON CO.,LTD. All Rights Reserved.
  4. http://www.lockon.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.     .c-detail-product__title {
  13.     color: #807245;
  14.  }
  15.  .c-detail-product__price-selling--number {
  16.     color: #f00;
  17. }
  18. .c-detail-product__price-selling--tax {
  19.     color: #f00;
  20. }
  21. .c-detail-product__code--label, .c-detail-product__price-normal--label {
  22.     color: #000;
  23. }
  24. .c-detail-product__code--number, .c-detail-product__price-normal--number {
  25.     color: #000;
  26. }
  27. .c-detail-product__price-normal--tax {
  28.     color: #000;
  29. }
  30. .c-button--unelevated.is-secondary {
  31.     background-color: #807245;
  32. }
  33. .c-detail-product__category-list-item a {
  34.     color: #807245;
  35. }
  36. .c-button--unelevated.is-primary {
  37.     background-color: #000;
  38. }
  39. </style>
  40. {% endblock %}
  41. {% block javascript %}
  42.     <script src="{{ asset('assets/js/eccube.js') }}"></script>
  43.     <script src="https://cdn.jsdelivr.net/npm/swiper@5.3.6/js/swiper.min.js" integrity="sha256-dwAIpWA5jmq1E3AHBeJDH86emZuOEMKZrZxNr9DJAQs=" crossorigin="anonymous"></script>
  44.     <script>
  45.         eccube.classCategories = {{ class_categories_as_json(Product)|raw }};
  46.         // 規格2に選択肢を割り当てる。
  47.         function fnSetClassCategories(form, classcat_id2_selected) {
  48.             var $form = $(form);
  49.             var product_id = $form.find('input[name=product_id]').val();
  50.             var $sele1 = $form.find('select[name=classcategory_id1]');
  51.             var $sele2 = $form.find('select[name=classcategory_id2]');
  52.             eccube.setClassCategories($form, product_id, $sele1, $sele2, classcat_id2_selected);
  53.         }
  54.         {% if form.classcategory_id2 is defined %}
  55.             fnSetClassCategories(
  56.                 $('#form1'), {{ form.classcategory_id2.vars.value|json_encode|raw }}
  57.             );
  58.         {% elseif form.classcategory_id1 is defined %}
  59.             eccube.checkStock($('#form1'), {{ Product.id }}, {{ form.classcategory_id1.vars.value|json_encode|raw }}, null);
  60.         {% endif %}
  61.         $(function() {
  62.             // bfcache無効化
  63.             $(window).bind('pageshow', function(event) {
  64.                 if (event.originalEvent.persisted) {
  65.                     location.reload(true);
  66.                 }
  67.             });
  68.             $('.add-cart').on('click', function(event) {
  69.                 {% if form.classcategory_id1 is defined %}
  70.                     // 規格1フォームの必須チェック
  71.                     if ($('#classcategory_id1').val() == '__unselected' || $('#classcategory_id1').val() == '') {
  72.                         $('#classcategory_id1')[0].setCustomValidity('{{ '項目が選択されていません'|trans }}');
  73.                         return true;
  74.                     } else {
  75.                         $('#classcategory_id1')[0].setCustomValidity('');
  76.                     }
  77.                 {% endif %}
  78.                 {% if form.classcategory_id2 is defined %}
  79.                     // 規格2フォームの必須チェック
  80.                     if ($('#classcategory_id2').val() == '__unselected' || $('#classcategory_id2').val() == '') {
  81.                         $('#classcategory_id2')[0].setCustomValidity('{{ '項目が選択されていません'|trans }}');
  82.                         return true;
  83.                     } else {
  84.                         $('#classcategory_id2')[0].setCustomValidity('');
  85.                     }
  86.                 {% endif %}
  87.                 // 個数フォームのチェック
  88.                 if ($('#quantity').val() < 1) {
  89.                     $('#quantity')[0].setCustomValidity('{{ '1以上で入力してください。'|trans }}');
  90.                     return true;
  91.                 } else {
  92.                     $('#quantity')[0].setCustomValidity('');
  93.                 }
  94.                 event.preventDefault();
  95.                 $form = $('#form1');
  96.                 $.ajax({
  97.                     url: $form.attr('action'),
  98.                     type: $form.attr('method'),
  99.                     data: $form.serialize(),
  100.                     dataType: 'json',
  101.                     beforeSend: function(xhr, settings) {
  102.                         // Buttonを無効にする
  103.                         $('.add-cart').prop('disabled', true);
  104.                     }
  105.                 }).done(function(data) {
  106.                     // レスポンス内のメッセージをalertで表示
  107.                     $.each(data.messages, function() {
  108.                         $('#js-product__modal-message').html(this);
  109.                     });
  110.                     $('.js-product__modal-checkbox').prop('checked', true);
  111.                     // カートブロックを更新する
  112.                     $.ajax({
  113.                         url: "{{ url('block_cart') }}",
  114.                         type: 'GET',
  115.                         dataType: 'html'
  116.                     }).done(function(html) {
  117.                         $('#js-header__utility-cart').html(html);
  118.                     });
  119.                 }).fail(function(data) {
  120.                     alert('{{ 'カートへの追加に失敗しました。'|trans }}');
  121.                 }).always(function(data) {
  122.                     // Buttonを有効にする
  123.                     $('.add-cart').prop('disabled', false);
  124.                 });
  125.             });
  126.             var galleryThumbs = new Swiper('#js-detail-product__gallery-thumbs', {
  127.                 slidesPerView: 4,
  128.                 spaceBetween: 16,
  129.                 freeMode: true,
  130.                 watchSlidesVisibility: true,
  131.                 watchSlidesProgress: true
  132.             });
  133.             var galleryTop = new Swiper('#js-product__detail-gallery-slide', {
  134.                 slidesPerView: 1,
  135.                 spaceBetween: 20,
  136.                 thumbs: {
  137.                     swiper: galleryThumbs
  138.                 },
  139.                 pagination: {
  140.                     el: '#js-detail-product__gallery-pager-contents',
  141.                     clickable: true
  142.                 },
  143.                 breakpoints: {
  144.                     479: {
  145.                         slidesPerView: 1,
  146.                         spaceBetween: 16
  147.                     }
  148.                 }
  149.             });
  150.             bgHeight($('#js-detail-product__price'));
  151.         });
  152.         var resizeTimer = null;
  153.         $(window).on('resize', function() {
  154.             clearTimeout(resizeTimer);
  155.             resizeTimer = setTimeout(function() {
  156.                 bgHeight($('#js-detail-product__price'));
  157.             }, 200);
  158.         });
  159.         function bgHeight(elem){
  160.             var elemOffsetTop = elem.offset().top,
  161.                 elemHeight = elem.outerHeight();
  162.             $('#js-layout__body-bg').height(elemOffsetTop + elemHeight);
  163.         }
  164.     </script>
  165. {% endblock %}
  166. {% block main %}
  167.     <div class="p-product">
  168.         <div class="p-product__contents" id="js-product__contents">
  169.             <div class="p-product__detail" id="js-product__detail">
  170.                 <article class="c-detail-product">
  171.                     <div class="c-detail-product__gallery">
  172.                         <div class="c-detail-product__gallery-slide" id="js-product__detail-gallery-slide">
  173.                             <div class="c-detail-product__gallery-slide-contents swiper-wrapper">
  174.                                 {% for ProductImage in Product.ProductImage %}
  175.                                     <div class="c-detail-product__gallery-slide-item swiper-slide">
  176.                                         <div class="c-detail-product__image">
  177.                                             <img class="c-detail-product__image-pic" src="{{ asset(ProductImage, 'save_image') }}" alt="{{ Product.name }}">
  178.                                         </div>
  179.                                     </div>
  180.                                 {% else %}
  181.                                     <div class="c-detail-product__gallery-slide-item swiper-slide">
  182.                                         <div class="c-detail-product__image">
  183.                                             <img class="c-detail-product__image-pic" src="{{ asset(''|no_image_product, 'save_image') }}" alt="{{ Product.name }}">
  184.                                         </div>
  185.                                     </div>
  186.                                 {% endfor %}
  187.                             </div>
  188.                         </div>
  189.                         <div class="c-detail-product__gallery-thumbs" id="js-detail-product__gallery-thumbs">
  190.                             <div class="c-detail-product__gallery-thumbs-contents swiper-wrapper">
  191.                                 {% for ProductImage in Product.ProductImage %}
  192.                                     <div class="c-detail-product__gallery-thumbs-item swiper-slide">
  193.                                         <div class="c-detail-product__image">
  194.                                             <img class="c-detail-product__image-pic" src="{{ asset(ProductImage, 'save_image') }}" alt="{{ Product.name }}">
  195.                                         </div>
  196.                                     </div>
  197.                                 {% endfor %}
  198.                             </div>
  199.                         </div>
  200.                         <div class="c-detail-product__gallery-pager">
  201.                             <div class="c-detail-product__gallery-pager-contents" id="js-detail-product__gallery-pager-contents"></div>
  202.                         </div>
  203.                     </div>
  204.                     <div class="c-detail-product__profile">
  205.                         <div class="c-detail-product__profile-layout">
  206.                             {# タグ #}
  207.                             {% if Product.Tags is not empty %}
  208.                                 <div class="c-detail-product__profile-layout-item">
  209.                                     <div class="c-detail-product__tag">
  210.                                         <ul class="c-detail-product__tag-list">
  211.                                             {% for Tag in Product.Tags %}
  212.                                                 <li class="c-detail-product__tag-list-item" id="c-detail-product__tag-list-item--{{ Tag.id }}">
  213.                                                     <span class="c-detail-product__tag-text">{{ Tag }}</span>
  214.                                                 </li>
  215.                                             {% endfor %}
  216.                                         </ul>
  217.                                     </div>
  218.                                 </div>
  219.                             {% endif %}
  220. <!--
  221.                             <div class="c-detail-product__profile-layout-item">
  222.                                 <div class="c-detail-product__favorite">
  223.                                     {# お気に入り #}
  224.                                     {% if BaseInfo.option_favorite_product %}
  225.                                         <form action="{{ url('product_add_favorite', {id:Product.id}) }}" method="post">
  226.                                             {% if is_favorite == false %}
  227.                                                 <button class="c-detail-product__favorite-button c-ripple-surface mdc-ripple-surface" type="submit" id="favorite">
  228.                                                     <i class="c-detail-product__favorite-button-icon material-icons">favorite_border</i>
  229.                                                 </button>
  230.                                             {% else %}
  231.                                                 <button class="c-detail-product__favorite-button is-disabled c-ripple-surface mdc-ripple-surface" type="submit" id="favorite" disabled="disabled">
  232.                                                     <i class="c-detail-product__favorite-button-icon material-icons">favorite</i>
  233.                                                 </button>
  234.                                             {% endif %}
  235.                                         </form>
  236.                                     {% endif %}
  237.                                 </div>
  238.                             </div>
  239.                 -->
  240.                         </div>
  241.                         {# 商品名 #}
  242.                         <h1 class="c-detail-product__title">{{ Product.name }}</h1>
  243.                         {# 商品コード #}
  244.                         {% if Product.code_min is not empty %}
  245.                             <div class="c-detail-product__code">
  246.                                 <span class="c-detail-product__code--label">{{ '商品コード'|trans }}</span>
  247.                                 <span class="c-detail-product__code--number product-code-default">{{ Product.code_min }}{% if Product.code_min != Product.code_max %} ~ {{ Product.code_max }}{% endif %}</span>
  248.                             </div>
  249.                         {% endif %}
  250.                         <div class="c-detail-product__price" id="js-detail-product__price">
  251.                             {# 通常価格 #}
  252.                             <div class="c-detail-product__price-normal">
  253.                                 {% if Product.hasProductClass -%}
  254.                                     {% if Product.getPrice01Min is not null and Product.getPrice01IncTaxMin == Product.getPrice01IncTaxMax %}
  255.                                         <span class="c-detail-product__price-normal--label">{{ '通常価格'|trans }}</span>
  256.                                         <span class="c-detail-product__price-normal--number price01-default">{{ Product.getPrice01IncTaxMin|price }}</span>
  257.                                         <span class="c-detail-product__price-normal--tax">{{ '(税込)'|trans }}</span>
  258.                                     {% elseif Product.getPrice01Min is not null and Product.getPrice01Max is not null %}
  259.                                         <span class="c-detail-product__price-normal--label">{{ '通常価格'|trans }}</span>
  260.                                         <span class="c-detail-product__price-normal--number price01-default">{{ Product.getPrice01IncTaxMin|price }} ~ {{ Product.getPrice01IncTaxMax|price }}</span>
  261.                                         <span class="c-detail-product__price-normal--tax">{{ '(税込)'|trans }}</span>
  262.                                     {% endif %}
  263.                                 {% else %}
  264.                                     {% if Product.getPrice01Max is not null %}
  265.                                         <span class="c-detail-product__price-normal--label">{{ '通常価格'|trans }}</span>
  266.                                         <span class="c-detail-product__price-normal--number">{{ Product.getPrice01IncTaxMin|price }}</span>
  267.                                         <span class="c-detail-product__price-normal--tax">{{ '(税込)'|trans }}</span>
  268.                                     {% endif %}
  269.                                 {% endif %}
  270.                             </div>
  271.                             {# 販売価格 #}
  272.                             <div class="c-detail-product__price-selling">
  273.                                 {% if Product.hasProductClass -%}
  274.                                     {% if Product.getPrice02IncTaxMin == Product.getPrice02IncTaxMax %}
  275.                                         <span class="c-detail-product__price-selling--number price02-default">{{ Product.getPrice02IncTaxMin|price }}</span>
  276.                                         <span class="c-detail-product__price-selling--tax">{{ '(税込)'|trans }}</span>
  277.                                     {% else %}
  278.                                         <span class="c-detail-product__price-selling--number price02-default">{{ Product.getPrice02IncTaxMin|price }} ~ {{ Product.getPrice02IncTaxMax|price }}</span>
  279.                                         <span class="c-detail-product__price-selling--tax">{{ '(税込)'|trans }}</span>
  280.                                     {% endif %}
  281.                                 {% else %}
  282.                                     <span class="c-detail-product__price-selling--number">{{ Product.getPrice02IncTaxMin|price }}</span>
  283.                                     <span class="c-detail-product__price-selling--tax">{{ '(税込)'|trans }}</span>
  284.                                 {% endif %}
  285.                             </div>
  286.                         </div>
  287.                         {# 関連カテゴリ #}
  288.                         {% if Product.ProductCategories is not empty %}
  289.                             <dl class="c-detail-product__category">
  290.                                 <dt class="c-detail-product__category-label">{{ '関連カテゴリ'|trans }}</dt>
  291.                                 <dd class="c-detail-product__category-detail">
  292.                                     {% for ProductCategory in Product.ProductCategories %}
  293.                                         <ul class="c-detail-product__category-list u-list-sanitize">
  294.                                             {% for Category in ProductCategory.Category.path %}
  295.                                                 <li class="c-detail-product__category-list-item">
  296.                                                     <a class="c-detail-product__category-link" href="{{ url('product_list') }}?category_id={{ Category.id }}">{{ Category.name }}</a>
  297.                                                 </li>
  298.                                             {% endfor %}
  299.                                         </ul>
  300.                                     {% endfor %}
  301.                                 </dd>
  302.                             </dl>
  303.                         {% endif %}
  304.                         <form action="{{ url('product_add_cart', {id:Product.id}) }}" method="post" id="form1" name="form1">
  305.                             {% if Product.stock_find %}
  306.                                 {% if form.classcategory_id1 is defined %}
  307.                                     <div class="c-detail-product__form-box">
  308.                                         <div class="c-detail-product__form-box-item">
  309.                                             <div class="c-select mdc-select mdc-select--outlined">
  310.                                                 <i class="mdc-select__dropdown-icon"></i>
  311.                                                 {{ form_widget(form.classcategory_id1, {'attr': { 'class': 'c-select__native-control mdc-select__native-control' }}) }}
  312.                                                 <div class="mdc-notched-outline">
  313.                                                     <div class="mdc-notched-outline__leading"></div>
  314.                                                     <div class="mdc-notched-outline__notch"></div>
  315.                                                     <div class="mdc-notched-outline__trailing"></div>
  316.                                                 </div>
  317.                                             </div>
  318.                                             {{ form_errors(form.classcategory_id1, {'label_attr': {'class': 'mdc-select-helper-text mdc-select-helper-text--validation-msg'}}) }}
  319.                                         </div>
  320.                                     </div>
  321.                                     {% if form.classcategory_id2 is defined %}
  322.                                         <div class="c-detail-product__form-box">
  323.                                             <div class="c-detail-product__form-box-item">
  324.                                                 <div class="c-select mdc-select mdc-select--outlined">
  325.                                                     <i class="mdc-select__dropdown-icon"></i>
  326.                                                     {{ form_widget(form.classcategory_id2, {'attr': { 'class': 'c-select__native-control mdc-select__native-control' }}) }}
  327.                                                     <div class="mdc-notched-outline">
  328.                                                         <div class="mdc-notched-outline__leading"></div>
  329.                                                         <div class="mdc-notched-outline__notch"></div>
  330.                                                         <div class="mdc-notched-outline__trailing"></div>
  331.                                                     </div>
  332.                                                 </div>
  333.                                                 {{ form_errors(form.classcategory_id2, {'label_attr': {'class': 'mdc-select-helper-text mdc-select-helper-text--validation-msg'}}) }}
  334.                                             </div>
  335.                                         </div>
  336.                                     {% endif %}
  337.                                 {% endif %}
  338.                                 <div class="c-detail-product__form-box">
  339.                                     <div class="c-detail-product__form-box-item">
  340.                                         <div class="c-text-field mdc-text-field mdc-text-field--outlined{{ has_errors(form.quantity) ? ' mdc-text-field--invalid' }}">
  341.                                             {{ form_widget(form.quantity, {'attr': { 'class': 'c-text-field__input mdc-text-field__input' }}) }}
  342.                                             <div class="mdc-notched-outline">
  343.                                                 <div class="mdc-notched-outline__leading"></div>
  344.                                                 <div class="mdc-notched-outline__notch">
  345.                                                     <label class="c-floating-label mdc-floating-label" for="quantity">{{ '数量'|trans }}</label>
  346.                                                 </div>
  347.                                                 <div class="mdc-notched-outline__trailing"></div>
  348.                                             </div>
  349.                                         </div>
  350.                                         {{ form_errors(form.quantity, {'label_attr': {'class': 'mdc-text-field-helper-text mdc-text-field-helper-text--validation-msg'}}) }}
  351.                                     </div>
  352.                                 </div>
  353.                                 <div class="c-detail-product__actions">
  354.                                     <div class="c-detail-product__actions-item">
  355.                                         <button class="c-button is-secondary c-button--unelevated mdc-button mdc-button--unelevated add-cart" type="submit">
  356.                                             <span class="c-detail-product__button-label">{{ 'カートに入れる'|trans }}</span>
  357.                                         </button>
  358.                                     </div>
  359.                                 </div>
  360.                             {% else %}
  361.                                 <div class="c-detail-product__actions">
  362.                                     <div class="c-detail-product__actions-item">
  363.                                         <button class="c-button c-button--unelevated mdc-button mdc-button--unelevated" type="button" disabled="disabled">
  364.                                             <span class="c-detail-product__button-label">{{ 'SOLD OUT'|trans }}</span>
  365.                                         </button>
  366.                                     </div>
  367.                                 </div>
  368.                             {% endif %}
  369.                             {{ form_rest(form) }}
  370.                         </form>
  371.                         <div class="p-product__modal">
  372.                             <input class="p-product__modal-checkbox js-product__modal-checkbox" id="p-product__modal-checkbox" type="checkbox">
  373.                             <div class="p-product__modal-overlay">
  374.                                 <label class="p-product__modal-overlay-close" for="p-product__modal-checkbox"></label>
  375.                                 <div class="p-product__modal-contents">
  376.                                     <label class="p-product__modal-close" for="p-product__modal-checkbox">
  377.                                         <i class="p-product__modal-close-icon material-icons">close</i>
  378.                                     </label>
  379.                                     <div class="p-product__modal-header">
  380.                                         <p class="p-product__modal-message" id="js-product__modal-message">{{ 'カートに追加しました。'|trans }}</p>
  381.                                     </div>
  382.                                     <div class="p-product__modal-actions">
  383.                                         <div class="p-product__modal-actions-item">
  384.                                             <a class="p-product__modal-button c-button c-button--unelevated is-secondary mdc-button mdc-button--unelevated" href="{{ url('cart') }}">
  385.                                                 <span class="c-button__label mdc-button__label">{{ 'カートへ進む'|trans }}</span>
  386.                                             </a>
  387.                                         </div>
  388.                                         <div class="p-product__modal-actions-item">
  389.                                             <label class="p-product__modal-button c-button c-button--unelevated is-primary mdc-button mdc-button--unelevated" for="p-product__modal-checkbox">
  390.                                                 <span class="c-button__label mdc-button__label">{{ 'お買い物を続ける'|trans }}</span>
  391.                                             </label>
  392.                                         </div>
  393.                                     </div>
  394.                                 </div>
  395.                             </div>
  396.                         </div>
  397.                         {% if Product.description_detail %}
  398.                             <div class="c-detail-product__comment">{{ Product.description_detail|raw|nl2br }}</div>
  399.                         {% endif %}
  400.                         {% if Product.freearea %}
  401.                             {{ include(template_from_string(Product.freearea)) }}
  402.                         {% endif %}
  403.                     </div>
  404.                 </article>
  405.             </div>
  406.         </div>
  407.     </div>
  408. {% endblock %}