app/template/user_data/subscription_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. {% block stylesheet %}
  10.     <link rel="stylesheet" href="{{ asset('assets/css/page/_subscription_point.css', 'user_data') }}">
  11.     <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/slick-carousel@1.8.1/slick/slick-theme.min.css">
  12.     <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/slick-carousel@1.8.1/slick/slick.min.css">
  13.     <style>
  14.     .quantities{
  15.       display:none; /* フォームで送信する必要はあるため、非表示にして個数を触れないようにする */
  16.     }
  17.     .reservation4-add-cart{
  18.         justify-content: center;
  19.     }
  20.         .new {
  21.           position: absolute;
  22.           top: -1%;
  23.           left: -2%;
  24.           width: 41%;
  25.           background: linear-gradient(to top left, transparent 50%, #df0b75 50%);
  26.           z-index: 10;
  27.           display: flex;
  28.           align-items: center;
  29.           justify-content: center;
  30.           transform-origin: top left;
  31.           container-type: inline-size;
  32.           color: white;
  33.           clip-path: polygon(0 60%, 60% 0, 100% 0, 0 100%);
  34.           aspect-ratio: 1 / 1;
  35.         }
  36.             
  37.         .new-text {
  38.           position: absolute;
  39.           color: #ffffff;
  40.           font-weight: bold;
  41.           font-size: 20cqw;
  42.           text-align: center;
  43.           line-height: 3em;
  44.           transform: rotate(-45.5deg) translate(0%,-25%);
  45.         }
  46.     
  47.     .list-btn {
  48.         width:100%;
  49.     }
  50.     @media screen and (max-width: 820px) {
  51.     .list-btn {
  52.         width:50%;
  53.     }
  54.     }
  55.     .ec-modal {
  56.       display: none;
  57.       position: fixed;
  58.       top: 0;
  59.       left: 0;
  60.       z-index: 9999;
  61.       width: 100%;
  62.       height: 100%;
  63.     }
  64.     .ec-modal.small {
  65.       width: 30%;
  66.     }
  67.     .ec-modal.full {
  68.       width: 100%;
  69.       height: 100%;
  70.     }
  71.     .ec-modal .ec-modal-overlay {
  72.       display: flex;
  73.       justify-content: center;
  74.       align-items: center;
  75.       background-color: rgba(0, 0, 0, 0.3);
  76.       width: 100%;
  77.       height: 100%;
  78.     }
  79.     .ec-modal .ec-modal-wrap {
  80.       position: relative;
  81.       border-radius: 10px;
  82.       border: 1px solid #333;
  83.       background-color: #fff;
  84.       width: 40%;
  85.       margin: 20px;
  86.       padding: 40px 5px;
  87.       color: #555555;
  88.       text-decoration: none;
  89.     }
  90.     .ec-modal .ec-modal-close {
  91.       cursor: pointer;
  92.       position: absolute;
  93.       right: 20px;
  94.       top: 10px;
  95.       font-size: 20px;
  96.       height: 30px;
  97.       width: 20px;
  98.     }
  99.     .ec-modal .ec-modal-close:hover {
  100.       color: #4b5361;
  101.     }
  102.     .ec-modal .ec-modal-box {
  103.       text-align: center;
  104.       font-weight: 600;
  105.     }
  106.     .ec-modal .ec-role {
  107.       margin-top: 20px;
  108.     }
  109.     #ec-modal-header {
  110.         text-align: center;
  111.     }
  112.     .ec-role {
  113.         display: flex;
  114.         justify-content: space-around;
  115.     }
  116.     .ec-inlineBtn--cancel {
  117.         color: #09860d;
  118.         border: solid 1px #09860d;
  119.         border-radius: 50px;
  120.         padding: 10px;
  121.     }
  122.     .ec-inlineBtn--cancel:hover {
  123.         color: #ffffff;
  124.         background-color:#09860d;
  125.     }
  126.     .ec-inlineBtn--action {
  127.         color: #e8353e;
  128.         border: solid 1px #e8353e;
  129.         border-radius: 50px;
  130.         padding: 10px;
  131.     }
  132.     .ec-inlineBtn--action:hover {
  133.         color: #ffffff;
  134.         background-color:#e8353e ;
  135.     }
  136.     
  137.     /* このページだけ無効化 */
  138.     .product_page #sns-pc {
  139.       padding: 0 !important;
  140.     }
  141.     .product_page .header_inner1 {
  142.       margin-bottom: 0 !important;
  143.     }
  144.     
  145.     #site_header {
  146.         margin: 0px 15px 0 15px !important;
  147.     }
  148.     .danger{
  149.         color: #e8353e;
  150.         font-size: 12px;
  151.     }
  152.     </style>
  153. {% endblock %}
  154. {% set body_class = 'product_page' %}
  155. {% block javascript %}
  156.     <script src="https://cdn.jsdelivr.net/npm/slick-carousel@1.8.1/slick/slick.min.js"></script>
  157.     <script>
  158.         eccube.classCategories = {{ class_categories_as_json(Product)|raw }};
  159.         // 規格2に選択肢を割り当てる。
  160.         function fnSetClassCategories(form, classcat_id2_selected) {
  161.             var $form = $(form);
  162.             var product_id = $form.find('input[name=product_id]').val();
  163.             var $sele1 = $form.find('select[name=classcategory_id1]');
  164.             var $sele2 = $form.find('select[name=classcategory_id2]');
  165.             eccube.setClassCategories($form, product_id, $sele1, $sele2, classcat_id2_selected);
  166.         }
  167.         {% if form.classcategory_id2 is defined %}
  168.         fnSetClassCategories(
  169.             $('#form1'), {{ form.classcategory_id2.vars.value|json_encode|raw }}
  170.         );
  171.         {% elseif form.classcategory_id1 is defined %}
  172.         eccube.checkStock($('#form1'), {{ Product.id }}, {{ form.classcategory_id1.vars.value|json_encode|raw }}, null);
  173.         {% endif %}
  174.     </script>
  175.     <script>
  176.         $(function() {
  177.             $('.add-cart').on('click', function(event) {
  178.                 {% if form.classcategory_id1 is defined %}
  179.                 // 規格1フォームの必須チェック
  180.                 if ($('#classcategory_id1').val() == '__unselected' || $('#classcategory_id1').val() == '') {
  181.                     $('#classcategory_id1')[0].setCustomValidity('{{ '項目が選択されていません'|trans }}');
  182.                     return true;
  183.                 } else {
  184.                     $('#classcategory_id1')[0].setCustomValidity('');
  185.                 }
  186.                 {% endif %}
  187.                 {% if form.classcategory_id2 is defined %}
  188.                 // 規格2フォームの必須チェック
  189.                 if ($('#classcategory_id2').val() == '__unselected' || $('#classcategory_id2').val() == '') {
  190.                     $('#classcategory_id2')[0].setCustomValidity('{{ '項目が選択されていません'|trans }}');
  191.                     return true;
  192.                 } else {
  193.                     $('#classcategory_id2')[0].setCustomValidity('');
  194.                 }
  195.                 {% endif %}
  196.                 // 個数フォームのチェック
  197.                 if ($('#quantity').val() < 1) {
  198.                     $('#quantity')[0].setCustomValidity('{{ '1以上で入力してください。'|trans }}');
  199.                     return true;
  200.                 } else {
  201.                     $('#quantity')[0].setCustomValidity('');
  202.                 }
  203.                 event.preventDefault();
  204.                 $form = $('#form1');
  205.                 $.ajax({
  206.                     url: $form.attr('action'),
  207.                     type: $form.attr('method'),
  208.                     data: $form.serialize(),
  209.                     dataType: 'json',
  210.                     beforeSend: function(xhr, settings) {
  211.                         // Buttonを無効にする
  212.                         $('.add-cart').prop('disabled', true);
  213.                     }
  214.                 }).done(function(data) {
  215.                     // レスポンス内のメッセージをalertで表示
  216.                     $.each(data.messages, function() {
  217.                         $('#ec-modal-header').html(this);
  218.                     });
  219.                     $('.ec-modal').show()
  220.                     // カートブロックを更新する
  221.                     $.ajax({
  222.                         url: "{{ url('block_cart') }}",
  223.                         type: 'GET',
  224.                         dataType: 'html'
  225.                     }).done(function(html) {
  226.                         $('.ec-headerRole__cart').html(html);
  227.                     });
  228.                 }).fail(function(data) {
  229.                     alert('{{ 'カートへの追加に失敗しました。'|trans }}');
  230.                 }).always(function(data) {
  231.                     // Buttonを有効にする
  232.                     $('.add-cart').prop('disabled', false);
  233.                 });
  234.             });
  235.         });
  236.         $('.ec-modal-wrap').on('click', function(e) {
  237.             // モーダル内の処理は外側にバブリングさせない
  238.             e.stopPropagation();
  239.         });
  240.         $('.ec-modal-overlay, .ec-modal, .ec-modal-close, .ec-inlineBtn--cancel').on('click', function() {
  241.             $('.ec-modal').hide()
  242.         });
  243.     </script>
  244.     <script type="application/ld+json">
  245.     {
  246.         "@context": "https://schema.org/",
  247.         "@type": "Product",
  248.         "name": "{{ Product.name }}",
  249.         "image": [
  250.             {% for img in Product.ProductImage %}
  251.                 "{{ app.request.schemeAndHttpHost }}{{ asset(img, 'save_image') }}"{% if not loop.last %},{% endif %}
  252.             {% else %}
  253.                 "{{ app.request.schemeAndHttpHost }}{{ asset(''|no_image_product, 'save_image') }}"
  254.             {% endfor %}
  255.         ],
  256.         "description": "{{ Product.description_list | default(Product.description_detail) | replace({'\n': '', '\r': ''}) | slice(0,300) }}",
  257.         {% if Product.code_min %}
  258.         "sku": "{{ Product.code_min }}",
  259.         {% endif %}
  260.         "offers": {
  261.             "@type": "Offer",
  262.             "url": "{{ url('product_detail', {'id': Product.id}) }}",
  263.             "priceCurrency": "{{ eccube_config.currency }}",
  264.             "price": {{ Product.getPrice02IncTaxMin ? Product.getPrice02IncTaxMin : 0}},
  265.             "availability": "{{ Product.stock_find ? "InStock" : "OutOfStock" }}"
  266.         }
  267.     }
  268.     </script>
  269.     <script>
  270.         document.addEventListener('DOMContentLoaded', function() {
  271.             function adjustItems(selector,amount) {
  272.                 const items = document.querySelectorAll(selector);
  273.                 items.forEach((item, index) => {
  274.                     if (window.innerWidth <= 768) {
  275.                         item.style.display = index < amount ? 'block' : 'none';
  276.                     } else {
  277.                         item.style.display = 'block';
  278.                     }
  279.                 });
  280.             }
  281.         
  282.             adjustItems(".relation .card-2",3);
  283.             adjustItems(".recommended .card-2",3);
  284.             window.addEventListener('resize', adjustItems);
  285.         });
  286.     </script>
  287. {% endblock %}
  288. {% block main %}
  289.     {% set ProductClass = Product.ProductClasses|first %}
  290.     {% set price_ex = ProductClass.price02 %}
  291.     {% set price_in = ProductClass.price02IncTax %}
  292.     {% set tax_price = price_in - price_ex %}
  293.     {% if Product.Id == 1278 %}
  294.         {% set grant_point = (price_ex * 0.06) + 30 %}
  295.     {% elseif Product.Id == 1279 %}
  296.         {% set grant_point = price_ex * 0.06 %}
  297.     {% else %}
  298.         {% set grant_point = price_ex * 0.06 %}
  299.     {% endif %}
  300.     <section class="subsc-point-page">
  301.         <div class="subsc-point-page__inner">
  302.             <header class="subsc-point-page__header">
  303.                 <h1 class="subsc-point-page__title">
  304.                     <span class="subsc-point-page__title-main">
  305.                         <img src="{{ asset('assets/icon/title_ic_subscription.svg', 'user_data')}}" alt="" aria-hidden="true" class="subsc-point-page__title-icon">
  306.                         <span>{{ Product.name }}</span>
  307.                     </span>
  308.                     <span class="subsc-point-page__title-divider" aria-hidden="true"></span>
  309.                 </h1>
  310.             </header>
  311.             <div class="subsc-point-page__layout">
  312.                 <div class="subsc-point-page__main">
  313.                     <section class="subsc-box">
  314.                         <h2 class="subsc-box__title">商品情報</h2>
  315.                         <div class="subsc-product-card">
  316.                             <div class="subsc-product-card__thumb">
  317.                                 {% if Product.Id == 1278 %}
  318.                                     <img src="{{ asset('assets/img/subscription_point_purchase_1year.png', 'user_data') }}" alt="">
  319.                                 {% elseif Product.Id == 1279 %}
  320.                                     <img src="{{ asset('assets/img/is_subscription_point_purchase_one_month.png', 'user_data') }}" alt="">
  321.                                 {% else %}
  322.                                     <img src="{{ asset('assets/img/is_subscription_point_purchase_one_month.png', 'user_data') }}" alt="">
  323.                                 {% endif %}
  324.                             </div>
  325.                             <div class="subsc-product-card__body">
  326.                                 <dl class="subsc-product-card__list">
  327.                                     <div class="subsc-product-card__row">
  328.                                         <dt>商品名:</dt>
  329.                                         <dd>{{ Product.name }}</dd>
  330.                                     </div>
  331.                                     <div class="subsc-product-card__row">
  332.                                         <dt>月額:</dt>
  333.                                         <dd>{{ price_in|price }}(税込)</dd>
  334.                                     </div>
  335.                                     <div class="subsc-product-card__row">
  336.                                         <dt>付与ポイント:</dt>
  337.                                         <dd>{{ grant_point|number_format }}ポイント</dd>
  338.                                     </div>
  339.                                 </dl>
  340.                             </div>
  341.                         </div>
  342.                     </section>
  343.                     <section class="subsc-box">
  344.                         <h2 class="subsc-box__title">お手続きの前に</h2>
  345.                         <div class="subsc-notes">
  346.                         {% set raw = Product.description_detail|default('') %}
  347.                         {% if '<ul' in raw or '<li' in raw %}
  348.                           <div class="subsc-notes">
  349.                             {{ raw|raw }}
  350.                           </div>
  351.                         {% else %}
  352.                           {% set text = raw|striptags %}
  353.                           {% set text = text|replace({'\r\n':'\n','\r':'\n'})|trim %}
  354.                           {% set text = text|replace({'・': "\n・"}) %}
  355.                           {% set lines = text|split("\n") %}
  356.                           <div class="subsc-notes">
  357.                             {% set in_list = false %}
  358.                             {% for line in lines %}
  359.                               {% set line = line|trim %}
  360.                               {% if line == '' %}
  361.                               {% elseif line starts with '・' %}
  362.                                 {% if not in_list %}
  363.                                   <ul class="subsc-notes__list">
  364.                                   {% set in_list = true %}
  365.                                 {% endif %}
  366.                                 <li>{{ line|replace({'・':''})|trim }}</li>
  367.                               {% else %}
  368.                                 {% if in_list %}
  369.                                   </ul>
  370.                                   {% set in_list = false %}
  371.                                 {% endif %}
  372.                                 <p class="subsc-notes__p">{{ line }}</p>
  373.                               {% endif %}
  374.                             {% endfor %}
  375.                             {% if in_list %}
  376.                               </ul>
  377.                             {% endif %}
  378.                           </div>
  379.                         {% endif %}
  380.                         </div>
  381.                         <div class="subsc-switch-buttons">
  382.                             {% if Product.Id == 1279 %}
  383.                                 <a href="/subscription/detail/1278" class="subsc-switch-buttons__item">
  384.                                     <img src="{{ asset('assets/icon/title_ic_subscription.svg', 'user_data')}}"
  385.                                          alt="" aria-hidden="true" class="subsc-switch-buttons__icon">
  386.                                     <span class="subsc-switch-buttons__text">1年サブスク</span>
  387.                                 </a>
  388.                             {% elseif Product.Id == 1278 %}
  389.                                 <a href="/subscription/detail/1279" class="subsc-switch-buttons__item">
  390.                                     <img src="{{ asset('assets/icon/title_ic_subscription.svg', 'user_data')}}"
  391.                                          alt="" aria-hidden="true" class="subsc-switch-buttons__icon" style="left: 65px;">
  392.                                     <span class="subsc-switch-buttons__text">1ヶ月サブスク</span>
  393.                                 </a>
  394.                             {% endif %}
  395.                         </div>
  396.                     </section>
  397.                 </div>
  398.                 <aside class="ec-orderRole__summary subsc-point-page__summary">
  399.                     <div class="subsc-summary">
  400.                         <div class="ec-totalBox__spec">
  401.                             <span>付与ポイント:</span>
  402.                             <span class="ec-totalBox__price">{{ grant_point|number_format }}ポイント</span>
  403.                         </div>
  404.                         <div class="ec-totalBox__spec">
  405.                             <span>料金:</span>
  406.                             <span class="ec-totalBox__price">¥{{ price_ex|number_format }}</span>
  407.                         </div>
  408.                         <div class="ec-totalBox__spec">
  409.                             <span>消費税:</span>
  410.                             <span class="ec-totalBox__price">¥{{ tax_price|number_format }}</span>
  411.                         </div>
  412.                         <div class="ec-totalBox__total subsc-summary__total">
  413.                             <span>合計:</span>
  414.                             <span class="ec-totalBox__price">¥{{ price_in|number_format }}</span>
  415.                         </div>
  416.                         <form action="{{ url('product_add_cart', { id: Product.id }) }}" method="post" id="form1" name="form1">
  417.                             {% if Product.stock_find %}
  418.                                 <div class="ec-productRole__actions">
  419.                                     {% if form.classcategory_id1 is defined %}
  420.                                         <div class="subsc-hidden-fields">
  421.                                             <div class="ec-select">
  422.                                                 {{ form_row(form.classcategory_id1) }}
  423.                                                 {{ form_errors(form.classcategory_id1) }}
  424.                                             </div>
  425.                                             {% if form.classcategory_id2 is defined %}
  426.                                                 <div class="ec-select">
  427.                                                     {{ form_row(form.classcategory_id2) }}
  428.                                                     {{ form_errors(form.classcategory_id2) }}
  429.                                                 </div>
  430.                                             {% endif %}
  431.                                         </div>
  432.                                     {% endif %}
  433.                                     <div class="quantities hidden">
  434.                                         <p>数量:</p>
  435.                                         {{ form_widget(form.quantity) }}
  436.                                         {{ form_errors(form.quantity) }}
  437.                                     </div>
  438.                                 </div>
  439.                                 <div class="ec-totalBox__btn">
  440.                                     {% if Customer %}
  441.                                         {% if isSubscription %}
  442.                                             <p class="danger">現在有効になっているサブスクリプションを解除しないと購入できません。</p>
  443.                                         {% else %}
  444.                                             <button type="submit" class="ec-blockBtn--action add-cart">
  445.                                                 ポイント購入
  446.                                             </button>
  447.                                         {% endif %}
  448.                                     {% else %}
  449.                                         <p class="danger">ポイントを購入するためにはログインしてください</p>
  450.                                     {% endif %}
  451.                                     <a href="{{ app.request.headers.get('referer') ?: url('homepage') }}" class="ec-blockBtn--cancel">
  452.                                         戻る
  453.                                     </a>
  454.                                 </div>
  455.                             {% else %}
  456.                                 <div class="ec-totalBox__btn">
  457.                                     <button type="button" class="ec-blockBtn--action" disabled="disabled">
  458.                                         {{ 'ただいま品切れ中です。'|trans }}
  459.                                     </button>
  460.                                     <a href="{{ app.request.headers.get('referer') ?: url('homepage') }}" class="ec-blockBtn--cancel">
  461.                                         戻る
  462.                                     </a>
  463.                                 </div>
  464.                             {% endif %}
  465.                             {{ form_rest(form) }}
  466.                         </form>
  467.                     </div>
  468.                 </aside>
  469.             </div>
  470.         </div>
  471.     </section>
  472.     <div class="ec-modal">
  473.         <div class="ec-modal-overlay">
  474.             <div class="ec-modal-wrap">
  475.                 <span class="ec-modal-close">
  476.                     <span class="ec-icon">
  477.                         <img src="{{ asset('assets/icon/cross-dark.svg') }}" alt="">
  478.                     </span>
  479.                 </span>
  480.                 <div id="ec-modal-header" class="text-center">{{ 'カートに追加しました。'|trans }}</div>
  481.                 <div class="ec-modal-box">
  482.                     <div class="ec-role">
  483.                         <span class="ec-inlineBtn--cancel">{{ 'お買い物を続ける'|trans }}</span>
  484.                         <a href="{{ url('cart') }}" class="ec-inlineBtn--action">{{ 'カートへ進む'|trans }}</a>
  485.                     </div>
  486.                 </div>
  487.             </div>
  488.         </div>
  489.     </div>
  490. {% endblock %}