app/Plugin/Shiro8Download42/Resource/template/default/Product/list.twig line 1

Open in your IDE?
  1. <script>
  2. $(function() {
  3.     
  4.     var hasProductFileAndSignIns;
  5.     hasProductFileAndSignIns = {{ hasProductFileAndSignIn|json_encode|raw }};
  6.     
  7.     $.each(hasProductFileAndSignIns, function(index, value) {
  8.         var $cartbtn = $('.add-cart:eq(' + index + ')');
  9.         if (!value) {
  10.             $cartbtn.prop('disabled', true);
  11.             $cartbtn.text('{{ 'plugin_shiro8_download42.default.product.list.title1'|trans }}');
  12.         } else {
  13.             $cartbtn.prop('disabled', false);
  14.             $cartbtn.text('{{ 'front.product.add_cart'|trans }}');
  15.         }
  16.     })
  17.     
  18.     // 規格1選択時
  19.     $('select[name=classcategory_id1]')
  20.     .change(function() {
  21.         var $form = $(this).parents('form');
  22.         var product_id = $form.find('input[name=product_id]').val();
  23.         var $sele1 = $(this);
  24.         var $sele2 = $form.find('select[name=classcategory_id2]');
  25.         // 規格1のみの場合
  26.         if (!$sele2.length) {
  27.             checkShiro8Download($form, product_id, $sele1.val(), null);
  28.             
  29.         }
  30.     });
  31.     // 規格2選択時
  32.     $('select[name=classcategory_id2]')
  33.     .change(function() {
  34.         var $form = $(this).parents('form');
  35.         var product_id = $form.find('input[name=product_id]').val();
  36.         var $sele1 = $form.find('select[name=classcategory_id1]');
  37.         var $sele2 = $(this);
  38.         checkShiro8Download($form, product_id, $sele1.val(), $sele2.val());
  39.     });
  40. });
  41. function checkShiro8Download($form, product_id, classcat_id1, classcat_id2) {
  42.     {% if is_granted('ROLE_USER') == false %}
  43.         classcat_id2 = classcat_id2 ? classcat_id2 : '';
  44.         var classcat2;
  45.         classcat2 = {{ product_class_categories|json_encode|raw }};
  46.         
  47.         classcat2 = classcat2[product_id];
  48.         classcat2 = classcat2[classcat_id1]['#' + classcat_id2];
  49.         
  50.         // 在庫(品切れ)
  51.         var $cartbtn = $form.parents('.ec-shelfGrid__item').find('.add-cart');
  52.         if (classcat2 && classcat2.dl_find === true) {
  53.             $cartbtn.prop('disabled', true);
  54.             $cartbtn.text('{{ 'plugin_shiro8_download42.default.product.list.title1'|trans }}');
  55.         } else {
  56.             $cartbtn.prop('disabled', false);
  57.             $cartbtn.text('{{ 'front.product.add_cart'|trans }}');
  58.         }
  59.     {% endif %}
  60. }
  61. </script>