app/template/default/Block/new_item.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. {% block stylesheet %}
  9.     <style>
  10.         .stamps-listItem {
  11.          margin: 10px 0;
  12.         }
  13.         .stamps-top-buttons {
  14.           width: 100%;
  15.         }
  16.         .ec-newItemRole .ec-newItemRole__listItemTitle {
  17.             font-size: 20px;
  18.         }
  19.         .ec-newItemRole .ec-newItemRole__listItemPrice{
  20.             font-size: 20px;
  21.         }
  22.     </style>
  23. {% endblock %}
  24. {% block javascript %}
  25.     <script>
  26.         $(function() {
  27.             $('.add-cart').on('click', function(e) {
  28.                 var $form = $(this).parent();
  29.                 // 個数チェック
  30.                 var $quantity = $form.children().find('.quantity');
  31.                 if ($quantity.val() < 1) {
  32.                     $quantity[0].setCustomValidity('{{ 'front.product.invalid_quantity'|trans }}');
  33.                     setTimeout(function() {
  34.                         loadingOverlay('hide');
  35.                     }, 100);
  36.                     return true;
  37.                 } else {
  38.                     $quantity[0].setCustomValidity('');
  39.                 }
  40.                 e.preventDefault();
  41.                 $.ajax({
  42.                     url: $form.attr('action'),
  43.                     type: $form.attr('method'),
  44.                     data: $form.serialize(),
  45.                     dataType: 'json',
  46.                     beforeSend: function(xhr, settings) {
  47.                         // Buttonを無効にする
  48.                         $('.add-cart').prop('disabled', true);
  49.                     }
  50.                 }).done(function(data) {
  51.                     // レスポンス内のメッセージをalertで表示
  52.                     $.each(data.messages, function() {
  53.                         $('#ec-modal-header').html(this);
  54.                     });
  55.                     $('#ec-modal-checkbox').prop('checked', true);
  56.                     // カートブロックを更新する
  57.                     $.ajax({
  58.                         url: '{{ url('block_cart') }}',
  59.                         type: 'GET',
  60.                         dataType: 'html'
  61.                     }).done(function(html) {
  62.                         $('.ec-headerRole__cart').html(html);
  63.                     });
  64.                 }).fail(function(data) {
  65.                     alert('{{ 'front.product.add_cart_error'|trans }}');
  66.                 }).always(function(data) {
  67.                     // Buttonを有効にする
  68.                     $('.add-cart').prop('disabled', false);
  69.                 });
  70.             });
  71.         });
  72.     </script>
  73. {% endblock %}
  74. <div class="ec-role">
  75.   <div class="ec-newItemRole">
  76.     <div class="ec-newItemRole__list">
  77.       <div class="row">
  78.         <div class="col-12">
  79.           <div class="row">
  80.             {% for Product in products %}
  81.             <div class="col-xs-12 col-md-6 stamps-listItem">
  82.               {# 商品画像 #}
  83.               <a href="{{ url('product_detail', {'id': Product.id}) }}">
  84.                 <img src="{{ asset(Product.main_list_image|no_image_product, 'save_image') }}">
  85.               </a>
  86.               {# 商品名 #}
  87.               <a href="{{ url('product_detail', {'id': Product.id}) }}">
  88.                 <p class="ec-newItemRole__listItemTitle">{{ Product.name }}</p>
  89.               </a>
  90.               {# 商品価格 #}
  91.               <p class="ec-newItemRole__listItemPrice">
  92.                 {% if Product.hasProductClass %} 
  93.                   {% if Product.getPrice02Min == Product.getPrice02Max %}
  94.                     {{ Product.getPrice02IncTaxMin|price }}
  95.                   {% else %}
  96.                     {{ Product.getPrice02IncTaxMin|price }} ~ {{ Product.getPrice02IncTaxMax|price }}
  97.                  {% endif %}
  98.                  {% else %}
  99.                    {{ Product.getPrice02IncTaxMin|price }}
  100.                 {% endif %}
  101.               </p>
  102.               <div class="row">
  103.                 <div class="col-lg-6">
  104.                  {# カート投入ボタン #}
  105.                  {% set form = forms[Product.id] %}
  106.                  <form name="form{{ Product.id }}" id="productForm{{ Product.id }}" action="{{ url('product_add_cart', {id:Product.id}) }}" method="post" >
  107.                      <div class="ec-productRole__actions">
  108.                          {% if form.classcategory_id1 is defined %}
  109.                              <div class="ec-select">
  110.                                  {{ form_widget(form.classcategory_id1) }}
  111.                                  {{ form_errors(form.classcategory_id1) }}
  112.                              </div>
  113.                              {% if form.classcategory_id2 is defined %}
  114.                                  <div class="ec-select">
  115.                                      {{ form_widget(form.classcategory_id2) }}
  116.                                      {{ form_errors(form.classcategory_id2) }}
  117.                                  </div>
  118.                              {% endif %}
  119.                          {% endif %}
  120.                          <div class="ec-numberInput">{# <span>{{ 'common.quantity'|trans }}</span> #}
  121.                              {{ form_widget(form.quantity, {'type': 'hidden', 'attr': {'class': 'quantity'}}) }}
  122.                              {{ form_errors(form.quantity) }}
  123.                          </div>
  124.                      </div>
  125.                      {{ form_rest(form) }}
  126.                      <input type="image" src="{{ asset('assets/imgs/button-cart.png','user_data') }}" class="add-cart stamps-top-buttons" data-cartid="{{ Product.id }}" form="productForm{{ Product.id }}" style="" onClick="">
  127.                  </form>
  128.                 </div>
  129.                 <div class="col-lg-6">
  130.                   {# 「レポートを見る」ボタン #}
  131.                     <a href="{{ url('product_detail', {'id': Product.id}) }}#report">
  132.                       <img src="{{ asset('assets/imgs/button-report.png','user_data') }}" class="go-report stamps-top-buttons"  style="" onClick=""/>
  133.                     </a>
  134.                   </a>
  135.                 </div>
  136.               </div>
  137.             </div>
  138.             {% endfor %}
  139.           </div>
  140.         </div>
  141.       </div>
  142.     </div>
  143.   </div>
  144. </div>
  145. <div class="ec-modal">
  146.     <input type="checkbox" id="ec-modal-checkbox" class="checkbox">
  147.     <div class="ec-modal-overlay">
  148.         <label for="ec-modal-checkbox" class="ec-modal-overlay-close"></label>
  149.         <div class="ec-modal-wrap">
  150.             <label for="ec-modal-checkbox" class="ec-modal-close"><span class="ec-icon"><img src="{{ asset('assets/icon/cross-dark.svg') }}" alt=""/></span></label>
  151.             <div id="ec-modal-header" class="text-center">{{ 'front.product.add_cart_complete'|trans }}</div>
  152.             <div class="ec-modal-box">
  153.                 <div class="ec-role">
  154.                     <label for="ec-modal-checkbox" class="ec-inlineBtn--cancel">{{ 'front.product.continue'|trans }}</label>
  155.                     <a href="{{ url('cart') }}" class="ec-inlineBtn--action">{{ 'common.go_to_cart'|trans }}</a>
  156.                 </div>
  157.             </div>
  158.         </div>
  159.     </div>
  160. </div>