1jQuery(document).ready(function($) { 2 //hang on event of form with id=myform 3 $('body').on('click', '.request-pricing-submit', function(e) { 4 // Check if name and email are filled out. 5 var form_data_name = $('#myform').find('input[name="name"]').val(); 6 if( form_data_name === '' ){ 7 $('#myform').find('.request-price-output').text('Please Enter Your Name').addClass('request-price-error').show(); 8 return false; 9 } 10 var form_data_email = $('#myform').find('input[name="email"]').val(); 11 if( form_data_email === '' ){ 12 $('#myform').find('.request-price-output').text('Please Enter Your Email').addClass('request-price-error').show(); 13 return false; 14 } 15 16 //prevent Default functionality 17 e.preventDefault(); 18 19 // Hdie any previous errors 20 $('#myform').find('.request-price-output').hide(); 21 $('#myform').find('.request-price-output').removeClass('request-price-error request-price-success'); 22 23 //do your own request an handle the results 24 $.ajax({ 25 url: '/wp-json/manager/v2/request/price', 26 type: 'post', 27 dataType: 'json', 28 data: $("#myform").serialize(), 29 success: function(data) { 30 console.log(data); 31 if( data.status === 'error' ){ 32 $('#myform').find('.request-price-output').text(data.msg).addClass('request-price-error').show(); 33 } else { 34 $('#myform').find('.request-price-output').text(data.msg).addClass('request-price-success').show(); 35 } 36 }, 37 }); 38 }); 39 40 41 42 43 44 // TEST CODE 45 $( ".variations_form" ).on( "woocommerce_variation_select_change", function () { 46 console.log('woocommerce_variation_select_change fired'); 47 } ); 48 49 $( document.body ).on( "found_variation", function ( event, variation ) { 50 console.log('found_variation fired'); 51 console.log(variation); 52 53 // Get variations_form 54 $variations_form = $(this).closest('.variations_form'); 55 56 if( variation.display_regular_price === 0 ){ 57 console.log('display_regular_price is zero'); 58 //$variations_form.find('.woocommerce-variation-add-to-cart').hide(); 59 } else { 60 //$variations_form.find('.woocommerce-variation-add-to-cart').show(); 61 } 62 } ); 63})
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.