1(function ($) { 2 /** 3 * refresh cart when payment method changed 4 */ 5 if (awdr_params.refresh_order_review == '1') { 6 $(document).on('change', 'input[name="payment_method"],input[name="billing_city"],input[name="billing_postcode"]', function () { 7 refreshCart(); 8 }); 9 10 /** 11 * refresh cart when Email changed 12 */ 13 $(document).on('blur', 'input[name="billing_email"], select#billing_state', function () { 14 refreshCart(); 15 }); 16 } 17 18 function refreshCart() { 19 $('body').trigger('update_checkout'); 20 } 21 22 $(document).ready(function ($) { 23 function init_events() { 24 if (awdr_params.enable_update_price_with_qty == 'show_dynamically') { 25 function getWDRDPTarget(form, target, is_variable){ 26 let $price_place = ''; 27 if (form.find(target).length) { 28 $price_place = form.find(target).first(); 29 if(is_variable === true){ 30 if (!form.find(target+' .price').length) { 31 $price_place.html("<div class='price'></div>"); 32 } 33 $price_place = form.find(target+' .price').first(); 34 } 35 } else { 36 $price_place = $(target).first(); 37 if(is_variable === true){ 38 if (!$(target+' .price').length) { 39 $price_place.html("<div class='price'></div>"); 40 } 41 $price_place = $(target+' .price').first(); 42 } 43 } 44 return $price_place; 45 } 46 $(document).on('change', '[name="quantity"]', function (){ 47 var awdr_qty_object = $(this); 48 setTimeout(function(){ 49 var $qty = awdr_qty_object.val(); 50 var $product_id = 0; 51 var $price_place = ""; 52 var form = awdr_qty_object.closest("form"); 53 if (form.find('button[name="add-to-cart"]').length) { 54 $product_id = form.find('button[name="add-to-cart"]').first().val(); 55 var target = 'div.product p.price'; 56 if(awdr_params.custom_target_simple_product != undefined){ 57 if(awdr_params.custom_target_simple_product != ""){ 58 target = awdr_params.custom_target_simple_product; 59 } 60 } 61 $price_place = getWDRDPTarget(form, target, false); 62 } else if (form.find('input[name="variation_id"]').length) { 63 $product_id = form.find('input[name="variation_id"]').val(); 64 var target = 'div.product .woocommerce-variation-price'; 65 if(awdr_params.custom_target_variable_product != undefined){ 66 if(awdr_params.custom_target_variable_product != ""){ 67 target = awdr_params.custom_target_variable_product; 68 } 69 } 70 $price_place = getWDRDPTarget(form, target, true); 71 } else if (form.find('input[name="add-to-cart"]').length) { 72 $product_id = form.find('input[name="add-to-cart"]').first().val(); 73 var target = 'div.product p.price'; 74 if(awdr_params.custom_target_simple_product != undefined){ 75 if(awdr_params.custom_target_simple_product != ""){ 76 target = awdr_params.custom_target_simple_product; 77 } 78 } 79 $price_place = getWDRDPTarget(form, target, false); 80 } 81 if(!$product_id || $product_id == 0){ 82 if(awdr_params.custom_simple_product_id_selector != undefined){ 83 if(awdr_params.custom_simple_product_id_selector != ""){ 84 let simple_product_id_selector = awdr_params.custom_simple_product_id_selector; 85 $product_id = $(simple_product_id_selector).val(); 86 let target = 'div.product p.price'; 87 if(awdr_params.custom_target_simple_product != undefined){ 88 if(awdr_params.custom_target_simple_product != ""){ 89 target = awdr_params.custom_target_simple_product; 90 } 91 } 92 $price_place = getWDRDPTarget(form, target, false); 93 } 94 } 95 96 if(awdr_params.custom_variable_product_id_selector != undefined){ 97 if(awdr_params.custom_variable_product_id_selector != ""){ 98 let variable_product_id_selector = awdr_params.custom_variable_product_id_selector; 99 $product_id = $(variable_product_id_selector).val(); 100 let target = 'div.product .woocommerce-variation-
100price'; 101 if(awdr_params.custom_target_variable_product != undefined){ 102 if(awdr_params.custom_target_variable_product != ""){ 103 target = awdr_params.custom_target_variable_product; 104 } 105 } 106 $price_place = getWDRDPTarget(form, target, true); 107 } 108 } 109 } 110 111 if (!$product_id || !$price_place || $product_id == 0) { 112 return; 113 } 114 115 var data = { 116 action: 'wdr_ajax', 117 method: 'get_price_html', 118 product_id: $product_id, 119 qty: $qty, 120 awdr_nonce: awdr_params.nonce, 121 }; 122 $.ajax({ 123 url: awdr_params.ajaxurl, 124 data: data, 125 type: 'POST', 126 success: function (response) { 127 if (response.price_html) { 128 $price_place.html(response.price_html) 129 } else { 130 if(response.original_price_html != undefined){ 131 $price_place.html(response.original_price_html) 132 } 133 } 134 // Trigger the custom price_updated event 135 $(document).trigger('wdr_dynamic_price_update', [response]); 136 }, 137 error: function (response) { 138 $price_place.html("") 139 } 140 }); 141 }, 0); 142 }); 143 } 144 } 145 146 if (awdr_params.js_init_trigger) { 147 $(document).on(awdr_params.js_init_trigger, function () { 148 init_events(); 149 }); 150 } 151 init_events(); 152 153 if (awdr_params.awdr_dynamic_bulk_table_status == "1") { 154 if(awdr_params.awdr_dynamic_bulk_table_off == "on"){ 155 function awdr_load_variation_table(variation_id){ 156 setTimeout(function(){ 157 if(variation_id != '' && variation_id != '0'){ 158 var data = { 159 action: 'wdr_ajax', 160 method: 'get_variable_product_bulk_table', 161 product_id: variation_id, 162 awdr_nonce: awdr_params.nonce, 163 }; 164 165 let awdr_opacity = 'div.awdr-bulk-customizable-table'; 166 167 if(awdr_params.awdr_opacity_to_bulk_table != undefined){ 168 if(awdr_params.awdr_opacity_to_bulk_table != ""){ 169 awdr_opacity = awdr_params.awdr_opacity_to_bulk_table; 170 } 171 } 172 173 $.ajax({ 174 url: awdr_params.ajaxurl, 175 data: data, 176 type: 'POST', 177 beforeSend: function () { 178 $(awdr_opacity).css('opacity','0.5'); 179 }, 180 complete: function () { 181 $(awdr_opacity).css('opacity','1'); 182 }, 183 success: function (response) { 184 if (response.bulk_table) { 185 $('.awdr-bulk-customizable-table').html(response.bulk_table); 186 } 187 }, 188 error: function (response) { 189 $('.awdr-bulk-customizable-table').html("") 190 } 191 }); 192 } 193 }, 100); 194 } 195 $( ".single_variation_wrap" ).on( "hide_variation", function ( event ) { 196 let variation_id = $(this).closest('form').find('input[name="product_id"]').val(); 197 awdr_load_variation_table(variation_id); 198 }); 199 $( ".single_variation_wrap" ).on( "show_variation", function ( event, variation, purchasable ) { 200 let variation_id = variation.variation_id; 201 if(variation.is_bundled != undefined){ 202 if(variation.is_bundled == true){ 203 return; 204 } 205 } 206 awdr_load_variation_table(variation_id); 207 }); 208 } 209 } 210 }); 211})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.