1jQuery(function($){ 2 3 window.wpuf_validate_address = function(e) { 4 var country = $("td.bill_required").find('.wpuf_biiling_country, .input'); 5 var state = $("td.bill_required").find('.wpuf_biiling_state, .input'); 6 var add_1 = $("#wpuf_biiling_add_line_1"); 7 var add_2 = $("#wpuf_biiling_add_line_2"); 8 var city = $("#wpuf_biiling_city"); 9 var zip = $("#wpuf_biiling_zip_code"); 10 var isValid = true; 11 12 if ( ( country.val() === '' || state.val() === '' ) || 13 ( add_1.hasClass('bill_required') && add_1.val() === "" ) || 14 ( add_2.hasClass('bill_required') && add_2.val() === "" ) || 15 ( city.hasClass('bill_required') && city.val() === "" ) || 16 ( zip.hasClass('bill_required') && zip.val() === "" ) ) 17 { 18 isValid = false; 19 } 20 return isValid; 21 }; 22 23 $( '#wpuf-payment-gateway' ).submit(function (e) { 24 // Stripe intercepts and processes the payment itself via AJAX â skip this handler entirely. 25 if ( $( this ).find( "input[name='wpuf_payment_method']:checked" ).val() === 'stripe' ) { 26 return; 27 } 28 29 let form_data = WP_User_Frontend.validateForm($(this)); 30 31 if (!form_data) { 32 e.preventDefault(); 33 } 34 35 var billing_address_form = $( '#wpuf-ajax-address-form' ); 36 37 if ( billing_address_form.length ) { 38 var inputs = [ 39 { id: '#wpuf_biiling_country', name: 'billing_country' }, 40 { id: '#wpuf_biiling_state', name: 'billing_state' }, 41 { id: '#wpuf_biiling_add_line_1', name: 'billing_add_line1' }, 42 { id: '#wpuf_biiling_add_line_2', name: 'billing_add_line2' }, 43 { id: '#wpuf_biiling_city', name: 'billing_city' }, 44 { id: '#wpuf_biiling_zip_code', name: 'billing_zip' }, 45 ]; 46 47 inputs.map( function ( input ) { 48 $( '<input type="hidden" name="billing_address[' + input.name + ']" />' ) 49 .appendTo( '#wpuf-payment-gateway' ) 50 .val( $( input.id ).val() ); 51 } ); 52 } 53 }); 54 55 $('#wpuf-ajax-address-form').submit(function (e) { 56 e.preventDefault(); 57 $( '#wpuf-payment-gateway' ).trigger( 'submit' ); 58 }); 59 60 $( document.body ).on('change', 'select#wpuf_biiling_country', function() { 61 var $this = $(this), $tr = $this.closest('tr'); 62 var data = { 63 action: 'wpuf_ajax_address', 64 country: $(this).val(), 65 field_name: $("#wpuf_biiling_state").attr("name"), 66 _wpnonce: $("#_wpnonce").val() 67 }; 68 $.post(ajax_object.ajaxurl, data, function (response) { 69 if( 'nostates' == response ) { 70 var text_field = '<input type="text" name="' + data.field_name + '" value=""/>'; 71 $this.parent().next().find('select').replaceWith( text_field ); 72 } else { 73 $this.parent().next().find('input,select').show(); 74 $this.parent().next().find('input,select').replaceWith(response); 75 $this.parent().next().find('input,select').prepend("<option value='' selected='selected'>- select -</option>"); 76 } 77 }); 78 }); 79 80 $(document).ready( function () { 81 wpuf_calculate_tax(); 82 }); 83 84 $(document.body).on('change', 'form#wpuf-ajax-address-form', function () { 85 wpuf_calculate_tax(); 86 }); 87 88 var ajax_tax_count = 0; 89 90 function wpuf_calculate_tax() { 91 92 var $wpuf_cc_address = jQuery('#wpuf-address-country-state'); 93 var $payment_form = jQuery('#wpuf-payment-gateway'); 94 var $address_form = jQuery('#wpuf-ajax-address-form'); 95 96 if ( ! $address_form.length ) { 97 return; 98 } 99 100 var postData = { 101 action: 'wpuf_update_billing_address', 102 billing_country: $wpuf_cc_address.find('#wpuf_biiling_country').val(), 103 billing_state: $wpuf_cc_address.find('#wpuf_biiling_state').val(), 104 billing_add_line1: $wpuf_cc_address.find('#wpuf_biiling_add_line_1').val(), 105 billing_add_line2: $wpuf_cc_address.find('#wpuf_biiling_add_line_2').val(), 106 billing_city: $wpuf_cc_address.find('#wpuf_biiling_city').val(), 107 billing_zip: $wpuf_cc_address.find('#wpuf_biiling_zip_code').val(), 108 type: $payment_form.find('#wpuf_type').html(), 109 id: $payment_form.find('#wpuf_id').html(), 110 _wpnonce: $address_form.find('#_wpnonce').val(), 111 }; 112 113 var current_ajax_count = ++ajax_tax_count; 114 jQuery.ajax({ 115 type: "POST", 116 data: postData, 117 dataType: "json", 118 url: ajax_object.ajaxurl, 119 success: function (tax_response) { 120 // Only update tax info if this response is the most recent ajax call. This avoids bug with form autocomplete firing multiple ajax calls at the same time 121 if ((current_ajax_count === ajax_tax_count) && tax_response) { 122 jQuery('#wpuf_pay_page_tax').html(tax_response.tax); 123 jQuery('#wpuf_pay_page_total').html(tax_response.cost); 124 var tax_data = new Object(); 125 tax_data.postdata = postData; 126 tax_data.response = tax_response; 127 } 128 } 129 }).fail(function (data) { 130 if ( window.console && window.console.log ) { 131 console.log( data ); 132 } 133 }); 134 } 135});
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.