app/template/default/Block/top_new_weis.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. <div class="top-content-box">
  9.     <h2>ヴァイスシュヴァルツ おすすめカード</h2>
  10. {% set Category = repository("Eccube\\Entity\\Category").find(644) %}
  11. {%
  12.     set products = repository("Eccube\\Entity\\Product")
  13.     .getQueryBuilderBySearchData({'category_id': Category})
  14.     .setMaxResults(5)
  15.     .getQuery()
  16.     .getResult()
  17. %}
  18.     <div class="product-big-list">
  19. {% for Product in products %}
  20.         <div class="product-list-box">
  21.             <a href="{{ url('product_detail', {'id': Product.id}) }}">
  22.                 <img src="{{ asset(Product.main_list_image|no_image_product, 'save_image') }}">
  23.             </a>
  24.             <p>{{ Product.name }}</p>
  25.             <p class="price">
  26.                 {% if Product.hasProductClass %}
  27.                     {% if Product.getPrice02Min == Product.getPrice02Max %}
  28.                         {{ Product.getPrice02IncTaxMin|number_format }}
  29.                     {% else %}
  30.                         {{ Product.getPrice02IncTaxMin|number_format }} ~ {{ Product.getPrice02IncTaxMax|number_format }}
  31.                     {% endif %}
  32.                 {% else %}
  33.                     {{ Product.getPrice02IncTaxMin|number_format }}
  34.                 {% endif %}
  35.                 <span>円</span>
  36.             </p>
  37.             {% if Product.stock_find %}
  38.                 <div class="top-weis-spin">
  39.                 
  40.                 <form name="form{{ Product.id }}" id="productForm{{ Product.id }}" action="{{ url('product_add_cart', {id:Product.id}) }}" method="post">
  41.                     <label class="number-spinner-wrap">
  42.                         <input type="number" id="quantity{{ Product.id }}" name="quantity" required="required" min="1" maxlength="9" class="test5" value="1">
  43.                         <span class="spinner spinner-down"> <img src="{{ asset('/html/user_data/assets/img/minus.png') }}" class="numcursul" alt=""> </span>
  44.                         <span class="spinner spinner-up"> <img src="{{ asset('/html/user_data/assets/img/plus.png') }}" class="numcursul" alt=""> </span>
  45.                     </label>
  46.                     <input type="hidden" id="product_id{{ Product.id }}" name="product_id" value="{{ Product.id }}">
  47.                     <input type="hidden" id="ProductClass" name="ProductClass" value="{{ Product.ProductClasses[0].id }}">
  48.                     <input type="hidden" id="_token{{ Product.id }}" name="_token" value="{{ csrf_token('Eccube\\Form\\Type\\AddCartType') }}" />
  49.                 </form>
  50.                 </div>
  51.                 <div class="cart-in-btn">
  52.                     <button class="add-cart-custom" data-cartid="{{ Product.id }}" form="productForm{{ Product.id }}" type="submit"> カートに入れる </button>
  53.                 </div>
  54.             {% else %}
  55.                 <div class="cart-in-btn">
  56.                     <button type="button" class="add-cart-custom" disabled="disabled"> {{ '品切れ中'|trans }} </button>
  57.                 </div>
  58.             {% endif %}
  59.         </div>
  60. {% endfor %}
  61.     </div>
  62. </div>
  63. <script>
  64. $(document).ready(function() {
  65.   // プラスボタンがクリックされたとき
  66.   $('.top-weis-spin .spinner-up').click(function() {
  67.     // 対応する数量フィールドのIDを取得
  68.     var productId = $(this).closest('.top-weis-spin .number-spinner-wrap').find('input[type="number"]').attr('id');
  69.     
  70.     // 対応する数量フィールドの値を取得
  71.     var quantity = parseInt($('.top-weis-spin #' + productId).val());
  72.     // 値を増加させて数量フィールドに設定
  73.     $( '.top-weis-spin #' + productId).val(quantity + 1);
  74.   });
  75.   // マイナスボタンがクリックされたとき
  76.   $('.top-weis-spin .spinner-down').click(function() {
  77.     // 対応する数量フィールドのIDを取得
  78.     var productId = $(this).closest('.top-weis-spin .number-spinner-wrap').find('input[type="number"]').attr('id');
  79.     
  80.     // 対応する数量フィールドの値を取得
  81.     var quantity = parseInt($('.top-weis-spin #' + productId).val());
  82.     // 値を減少させて数量フィールドに設定 (1未満にはしない)
  83.     if (quantity > 1) {
  84.       $( '.top-weis-spin #' + productId).val(quantity - 1);
  85.     }
  86.   });
  87. });
  88. </script>