1jQuery(function($){ 2 //Refund request submit 3 $('.wps_rma_return_notification').hide(); 4 $( '#wps_rma_return_request_form' ).on('submit',function(e){ 5 e.preventDefault(); 6 var orderid = $( this ).data( 'orderid' ); 7 var alerthtml = ''; 8 var selected_product = new Array(); 9 var refund_method = ''; 10 var pro_act = wrael_common_param.check_pro_active; 11 var is_subject_missing = false; 12 var is_reason_missing = false; 13 14 var rr_subject = $( '#wps_rma_return_request_subject' ).val(); 15 16 if (rr_subject == '' || rr_subject == null ) { 17 rr_subject = $( '#wps_rma_return_request_subject_text' ).val(); 18 if (rr_subject == '' || rr_subject == null ) { 19 is_subject_missing = true; 20 } 21 } 22 var rr_reason = $( '.wps_rma_return_request_reason' ).val(); 23 if ( typeof( rr_reason ) !== 'undefined' && ( rr_reason == '' || rr_reason == null ) ) { 24 is_reason_missing = true; 25 } 26 27 if ( is_subject_missing && is_reason_missing ) { 28 alerthtml += '<li>' + wrael_common_param.return_subject_reason_msg + '</li>'; 29 } else if ( is_subject_missing ) { 30 alerthtml += '<li>' + wrael_common_param.return_subject_msg + '</li>'; 31 } else if ( is_reason_missing ) { 32 alerthtml += '<li>' + wrael_common_param.return_reason_msg + '</li>'; 33 } 34 if( pro_act && typeof wps_rma_return_alert_condition_addon == 'function' ){ 35 alerthtml += wps_rma_return_alert_condition_addon(); 36 } 37 var attachment_enable = wrael_common_param.refund_form_attachment; 38 if ( attachment_enable && 'on' == attachment_enable ) { 39 var refund_total_files = 0; 40 $('.wps_rma_return_request_files').each(function(){ 41 var up_files = $(this); 42 var totalfiles = up_files[0].files.length; 43 refund_total_files += totalfiles; 44 if ( totalfiles ) { 45 var file_type = up_files[0].files[0].type; 46 47 var allowedTypes = [ 48 'image/png', 49 'image/jpeg', 50 'video/mp4', 51 'video/webm', 52 'video/ogg', 53 'video/quicktime', // mov 54 'video/x-msvideo' // avi 55 ]; 56 57 if ( ! allowedTypes.includes(file_type)) { 58 alerthtml += '<li>'+ wrael_common_param.file_not_supported + '</li>'; 59 } 60 } 61 }); 62 var attachment_mandatory = wrael_common_param.refund_form_attachment_mandatory; 63 if ( attachment_mandatory && 'on' == attachment_mandatory && ! refund_total_files ) { 64 alerthtml += '<li>'+ wrael_common_param.return_attachment_msg + '</li>'; 65 } 66 } 67 68 var wps_rma_customer_contact_refund = null; 69 var is_reached_max = false; 70 if( pro_act ){ 71 $('.wps_rma_return_column').each(function(){ 72 if($(this).find('.wps_wrma_return_product').is(':checked')){ 73 const item_id = $(this).data('item_id'); 74 const qty = $(this).find('.wps_rma_return_product_qty').val(); 75 var return_products = {}; 76 return_products.item_id = item_id; 77 return_products.qty = qty; 78 selected_product.push( return_products ); 79 80 const max_qty = $(this).find('.wps_rma_return_product_qty').attr('max'); 81 if( parseInt( qty ) > parseInt( max_qty ) ) { 82 is_reached_max = true; 83 } 84 } 85 }); 86 wps_rma_customer_contact_refund = $('#wps_rma_customer_contact_refund').val(); 87 if ( typeof wps_rma_return_alert_condition_addon == 'function' ) { 88 refund_method = wps_rma_refund_method(); 89 } 90 } else { 91 $('.wps_rma_return_column').each(function(){ 92 const item_id = $(this).data('item_id'); 93 const qty = $(this).find('.wps_rma_return_product_qty').val(); 94 var return_products = {}; 95 return_products.item_id = item_id; 96 return_products.qty = qty; 97 selected_product.push( return_products ); 98 99 const max_qty = $(this).find('.wps_rma_return_product_qty').attr('max'); 100 101 if( parseInt( qty ) > parseInt( max_qty ) ) { 102 is_reached_max = true; 103 } 104 }); 105 } 106 107 if ( is_reached_max ) { 108 alerthtml += '<li>'+wrael_common_param.correct_quantity+'</li>'; 109 } 110 var qty_error = false; 111 $.each( selected_product, function( index, data ){ 112 if (!Number.isInteger(parseInt(data.qty)) || parseInt(data.qty) <= 0) { 113 qty_error = true; 114 } 115 }); 116 if ( qty_error ) { 117 alerthtml += '<li>'+ wrael_common_param.qty_error + '</li>'; 118 } 119 if ( alerthtml == 'false' ) { 120 alerthtml = ''; 121 } 122 123 if (alerthtml != '') { 124 $( '#wps_rma_return_alert' ).show(); 125 $( '#wps_rma_return_alert' ).html( alerthtml ); 126 $( '#wps_rma_return_alert' ).addClass('woocommerce-error'); 127 $( '#wps_rma_return_alert' ).removeClass('woocommerce-message'); 128 $( 'html, body' ).animate( 129 { 130 scrollTop: $( '#wps_rma_return_request_container' ).offset().top 131 }, 132 800 133 ); 134 return false;
135 } else { 136 $( '#wps_rma_return_alert' ).hide(); 137 $( '#wps_rma_return_alert' ).html( alerthtml ); 138 } 139 140 var data = { 141 action :'wps_rma_save_return_request', 142 products: selected_product, 143 subject : rr_subject, 144 reason : rr_reason, 145 orderid : orderid, 146 order_key : $( this ).find( 'input[name="order_key"]' ).val(), 147 bankdetails : $( '#wps_rma_bank_details' ).val(), 148 refund_method : refund_method, 149 security_check : wrael_common_param.wps_rma_nonce, 150 all_product_checked : $('.wps_wrma_return_product_all').is(":checked"), 151 wps_rma_customer_contact_refund : wps_rma_customer_contact_refund, 152 } 153 154 var formData = new FormData(this); 155 formData.append('action', 'wps_rma_return_upload_files'); 156 formData.append('security_check', wrael_common_param.wps_rma_nonce); 157 $('.wps_rma_return_notification').show(); 158 $.ajax({ 159 url: wrael_common_param.ajaxurl, 160 type: 'POST', 161 data: formData, 162 contentType: false, 163 cache: false, 164 processData:false, 165 success: function(respond) 166 { 167 //Send return request 168 $.ajax({ 169 url: wrael_common_param.ajaxurl, 170 type: 'POST', 171 data: data, 172 dataType :'json', 173 success: function(response) 174 { 175 // Start redirect page countdown on refund request form 176 var timeleft = 10; 177 var downloadTimer = setInterval(function(){ 178 if(timeleft >= 0){ 179 $('#countdownTimer').html( timeleft ); 180 } 181 timeleft -= 1; 182 }, 1000); 183 184 // Start redirect page countdown on refund request form 185 $('#wps_rma_return_alert').removeClass('woocommerce-error'); 186 $('#wps_rma_return_alert').addClass('woocommerce-message'); 187 $('#wps_rma_return_alert' ).show(); 188 $('#wps_rma_return_alert').html( response.msg + ' in ' + '<b><span id="countdownTimer"></span>' + ' seconds</b>' ); 189 $('.wps_rma_return_notification').hide(); 190 $('html, body').animate({ 191 scrollTop: $('#wps_rma_return_request_container').offset().top 192 }, 800); 193 194 if(typeof response.auto_accept != 'undefined') { 195 if(response.auto_accept == true) { 196 if (typeof wps_rma_refund_auto_accept == 'function') { 197 wps_rma_refund_auto_accept(orderid); 198 } 199 } else { 200 window.setTimeout(function() { 201 window.location.href = wrael_common_param.myaccount_url; 202 }, 11000); 203 } 204 } else { 205 window.setTimeout(function() { 206 window.location.href = wrael_common_param.myaccount_url; 207 }, 11000); 208 } 209 } 210 }); 211 } 212 }); 213 }); 214 215 // Remove notice on the order message form. 216 $(document).on('click','.wps_remove_notice_msg',function(e) { 217 e.preventDefault(); 218 $('.wps_order_msg_notice_wrapper').hide(); 219 }); 220 221 // Send the order message frontend and backend with same code. 222 $( document ).on( 'click', '#wps_order_msg_submit', function (e) { 223 e.preventDefault(); 224 var up_files = $('#wps_order_msg_attachment'); 225 var msg = $('#wps_order_new_msg').val(); 226 var order_msg_type = $('#order_msg_type').val(); 227 var alerthtml = ''; 228 var order_id = $(this).data('id'); 229 230 var pro_act = wrael_common_param.check_pro_active; 231 var wps_rma_customer_contact_order_message = null; 232 if( pro_act ){ 233 wps_rma_customer_contact_order_message = $('#wps_rma_customer_contact_order_message').val(); 234 } 235 236 var form_data = new FormData(); 237 238 // Read selected files 239 var attachment_enable = wrael_common_param.order_msg_attachment; 240 if ( attachment_enable && 'on' == attachment_enable && up_files[0] ) { 241 var totalfiles = up_files[0].files.length; 242 if ( totalfiles ) { 243 for (var index = 0; index < totalfiles; index++) { 244 var file_type = up_files[0].files[index].type; 245 if ( 'image/png' == file_type || 'image/jpeg' == file_type || 'image/jpg' == file_type ) { 246 form_data.append('wps_order_msg_attachment[]', up_files[0].files[index]); 247 } else { 248 alerthtml = '<p class="wps_order_msg_sent_notice">'+ wrael_common_param.file_not_supported +'</p><a href="" class="wps_remove_notice_msg">X</a>'; 249 } 250 } 251 252 } 253 } 254 if ( msg == '' ) { 255 alerthtml = '<p class="wps_order_msg_sent_notice">'+ wrael_common_param.message_empty +'</p><a href="" class="wps_remove_notice_msg">X</a>'; 256 } 257 if ( alerthtml ) { 258 $('.wps_order_msg_notice_wrapper').css('display', 'flex'); 259 $('.wps_order_msg_notice_wrapper').css('background-color', 'red'); 260 $('.wps_order_msg_notice_wrapper').html(alerthtml); 261 $('#wps_order_msg_submit').css({'outline-color':'white', 'border-color':'white'}); 262 return false;
263 } 264 form_data.append( 'action', 'wps_rma_order_messages_save' ); 265 form_data.append( 'msg', msg ); 266 form_data.append( 'order_msg_type', order_msg_type ); 267 form_data.append( 'wps_rma_customer_contact_order_message', wps_rma_customer_contact_order_message ); 268 form_data.append( 'order_id', order_id ); 269 form_data.append( 'security_check', wrael_common_param.wps_rma_nonce ); 270 271 // AJAX request 272 $.ajax({ 273 url: wrael_common_param.ajaxurl, 274 type: 'post', 275 data: form_data, 276 dataType: 'json', 277 contentType: false, 278 processData: false, 279 success: function ( response ) { 280 if( response ) { 281 var html = '<p class="wps_order_msg_sent_notice">'+ wrael_common_param.message_sent +'</p><a href="" class="wps_remove_notice_msg">X</a>'; 282 $('.wps_order_msg_notice_wrapper').css('background-color', '#64CD83'); 283 $('.wps_order_msg_notice_wrapper').css('display', 'flex'); 284 $('#wps_order_msg_submit').css({'outline-color':'none', 'border-color':'none'}); 285 $('.wps_order_msg_sub_container').load(document.URL + ' .wps-order-msg__row'); 286 $('#wps_order_new_msg').val(''); 287 $('#wps_order_msg_attachment').val(''); 288 $('.wps_order_msg_notice_wrapper').html( html ); 289 } 290 } 291 }); 292 }); 293 294 // Order message refresh frontend and backend with same code. 295 $('.wps_order_msg_reload_notice_wrapper').hide(); 296 $(document).on('click','.wps_reload_messages',function(e) { 297 e.preventDefault(); 298 $(this).addClass('wps-loader-icon'); 299 $('.wps_order_msg_sub_container').load(document.URL + ' .wps-order-msg__row'); 300 setTimeout(function() { 301 $('.wps_reload_messages').removeClass('wps-loader-icon'); 302 $('.wps_order_msg_reload_notice_wrapper').show(); 303 $('.wps_order_msg_reload_notice_wrapper').css({ 304 'background-color':'rgb(100, 205, 131)', 305 'border-radius':'5px', 306 'color': 'white', 307 'padding-left': '10px' 308 }); 309 }, 2000); 310 setTimeout(function() { 311 $('.wps_order_msg_reload_notice_wrapper').hide(); 312 }, 3000); 313 }); 314 315 // dismiss send msg frontend and backend with same code. 316 $(document).on('click','.wps_order_send_msg_dismiss',function(e) { 317 e.preventDefault(); 318 $('.wps_order_msg_notice_wrapper').hide(); 319 }); 320 $( document ).on( 'submit', '#wps_rma_cancel_return_request', function(e){ 321 e.preventDefault(); 322 323 // Show confirmation alert 324 if (!confirm(wrael_common_param.return_cancellation_alert)) { 325 return; // Exit if the user clicks "Cancel" 326 } 327 const order_id = $('.wps_rma_cancel_return_request').val(); 328 const order_key = $('.wps_rma_cancel_return_request_key').val(); 329 330 var data = { 331 action :'wps_rma_cancel_return_request', 332 order_id: order_id, 333 order_key: order_key, 334 security_check : wrael_common_param.wps_rma_nonce, 335 } 336 //cancel return request 337 $.ajax({ 338 url: wrael_common_param.ajaxurl, 339 type: 'POST', 340 data: data, 341 dataType :'json', 342 success: function(response) 343 { 344 window.location.href = window.location.href; 345 } 346 }); 347 }); 348});
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.