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

Open in your IDE?
  1. {#
  2. * Plugin Name : DeliveryPlus4
  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.     DeliveryPlusParams = {{ DeliveryPlusParams|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.checkStockWeightSize($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.checkStockWeightSize($form, product_id, $sele1.val(), $sele2.val());
  29.         });
  30.     });
  31.     eccube.deliveryplus_weight_origin = [];
  32.     eccube.deliveryplus_size_origin = [];
  33.     eccube.checkStockWeightSize = function($form, product_id, classcat_id1, classcat_id2) {
  34.         classcat_id2 = classcat_id2 ? classcat_id2 : '';
  35.         var classcat3;
  36.         classcat3 = DeliveryPlusParams[product_id][classcat_id1]['#' + classcat_id2];
  37.         // 重さ
  38.         var $deliveryplus_weight = $form.parent().find('#deliveryplus_weight_default').first();
  39.         if (typeof this.deliveryplus_weight_origin[product_id] === 'undefined') {
  40.             this.deliveryplus_weight_origin[product_id] = $deliveryplus_weight.text();
  41.         }
  42.         if (classcat3 && typeof classcat3.weight !== 'undefined' && String(classcat3.weight).length >= 1) {
  43.             $deliveryplus_weight.text(classcat3.weight);
  44.         } else {
  45.             $deliveryplus_weight.text(this.deliveryplus_weight_origin[product_id]);
  46.         }
  47.         // サイズ
  48.         var $deliveryplus_size = $form.parent().find('#deliveryplus_size_default').first();
  49.         if (typeof this.deliveryplus_size_origin[product_id] === 'undefined') {
  50.             this.deliveryplus_size_origin[product_id] = $deliveryplus_size.text();
  51.         }
  52.         if (classcat3 && typeof classcat3.size !== 'undefined' && String(classcat3.size).length >= 1) {
  53.             $deliveryplus_size.text(classcat3.size);
  54.         } else {
  55.             $deliveryplus_size.text(this.deliveryplus_size_origin[product_id]);
  56.         }
  57.     };
  58. </script>