app/template/default/Product/js/list_script.twig line 1

Open in your IDE?
  1. <script>
  2.         eccube.productsClassCategories = {
  3.             {% for Product in pagination %}
  4.             "{{ Product.id|escape('js') }}": {{ class_categories_as_json(Product)|raw }}{% if loop.last == false %}, {% endif %}
  5.             {% endfor %}
  6.         };
  7.         $(function() {
  8.             // 表示件数を変更
  9.             $('.disp-number').change(function() {
  10.                 var dispNumber = $(this).val();
  11.                 $('#disp_number').val(dispNumber);
  12.                 $('#pageno').val(1);
  13.                 $("#form1").submit();
  14.             });
  15.             // 並び順を変更
  16.             $('.order-by').change(function() {
  17.                 var orderBy = $(this).val();
  18.                 $('#orderby').val(orderBy);
  19.                 $('#pageno').val(1);
  20.                 $("#form1").submit();
  21.             });
  22.             $('.add-cart').on('click', function(e) {
  23.                 var $form = $(this).parents('li').find('form');
  24.                 // 個数フォームのチェック
  25.                 var $quantity = $form.parent().find('.quantity');
  26.                 if ($quantity.val() < 1) {
  27.                     $quantity[0].setCustomValidity('{{ '1以上で入力してください。'|trans }}');
  28.                     setTimeout(function() {
  29.                         loadingOverlay('hide');
  30.                     }, 100);
  31.                     return true;
  32.                 } else {
  33.                     $quantity[0].setCustomValidity('');
  34.                 }
  35.                 e.preventDefault();
  36.                 $.ajax({
  37.                     url: $form.attr('action'),
  38.                     type: $form.attr('method'),
  39.                     data: $form.serialize(),
  40.                     dataType: 'json',
  41.                     beforeSend: function(xhr, settings) {
  42.                         // Buttonを無効にする
  43.                         $('.add-cart').prop('disabled', true);
  44.                     }
  45.                 }).done(function(data) {
  46.                     // レスポンス内のメッセージをalertで表示
  47.                     $.each(data.messages, function() {
  48.                         $('#ec-modal-header').html(this);
  49.                     });
  50.                     $('#ec-modal-checkbox').prop('checked', true);
  51.                     // カートブロックを更新する
  52.                     $.ajax({
  53.                         url: '{{ url('block_cart') }}',
  54.                         type: 'GET',
  55.                         dataType: 'html'
  56.                     }).done(function(html) {
  57.                         $('.ec-headerRole__cart').html(html);
  58.                     });
  59.                 }).fail(function(data) {
  60.                     alert('{{ 'サイズ等を選択してください。'|trans }}');
  61.                 }).always(function(data) {
  62.                     // Buttonを有効にする
  63.                     $('.add-cart').prop('disabled', false);
  64.                 });
  65.             });
  66.         });
  67.     </script>