app/Plugin/CustomerRank42/Resource/template/default/Product/product_js.twig line 1

Open in your IDE?
  1. {#
  2. * Plugin Name : CustomerRank
  3. *
  4. * Copyright (C) BraTech Co., Ltd. All Rights Reserved.
  5. * http://www.bratech.co.jp/
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. #}
  10. <script>
  11.     CustomerPrices = {{ CustomerPrices|json_encode|raw }};
  12.     $(function() {
  13.         // 規格1選択時
  14.         $('select[name=classcategory_id1]')
  15.         .change(function() {
  16.             var $form = $(this).parents('form');
  17.             var product_id = $form.find('input[name=product_id]').val();
  18.             var $sele1 = $(this);
  19.             eccube.checkStockCustomer($form, product_id, $sele1.val() , '');
  20.         });
  21.         // 規格2選択時
  22.         $('select[name=classcategory_id2]')
  23.         .change(function() {
  24.             var $form = $(this).parents('form');
  25.             var product_id = $form.find('input[name=product_id]').val();
  26.             var $sele1 = $form.find('select[name=classcategory_id1]');
  27.             var $sele2 = $(this);
  28.             eccube.checkStockCustomer($form, product_id, $sele1.val(), $sele2.val());
  29.         });
  30.     });
  31.     eccube.customer_rank_price_origin = [];
  32.     eccube.checkStockCustomer = function($form, product_id, classcat_id1, classcat_id2) {
  33.         if(!$form.parent().find('#customer_rank_price_default').length)return;
  34.         classcat_id2 = classcat_id2 ? classcat_id2 : '';
  35.         var classcat3;
  36.         classcat3 = CustomerPrices[product_id][classcat_id1]['#' + classcat_id2];
  37.         // 会員価格
  38.         var $customer_rank_price = $form.parent().find('#customer_rank_price_default').first();
  39.         if (typeof this.customer_rank_price_origin[product_id] === 'undefined') {
  40.             this.customer_rank_price_origin[product_id] = $customer_rank_price.text();
  41.         }
  42.         if (classcat3 && typeof classcat3.customer_rank_price_inc_tax !== 'undefined' && String(classcat3.customer_rank_price_inc_tax).length >= 1) {
  43.             $customer_rank_price.text('¥ ' + classcat3.customer_rank_price_inc_tax);
  44.         } else {
  45.             $customer_rank_price.text(this.customer_rank_price_origin[product_id]);
  46.         }
  47.     };
  48. </script>