1jQuery(document).ready(function($) { 2 /** 3 * Notices in checkout 4 */ 5 $( document.body ).on( 'updated_checkout', function() { 6 let noticesEl = $( '#wcs-notices-pending' ); 7 8 if ( noticesEl.length > 0 ) { 9 // Clear existing notices 10 $( '#wcs-notices' ).remove(); 11 12 let shippingMethods = $( '.woocommerce-shipping-totals ul.woocommerce-shipping-methods' ); 13 14 if ( shippingMethods.length > 0 ) { 15 shippingMethods.after( noticesEl ); 16 noticesEl.css( 'display', 'block' ).attr( 'id', 'wcs-notices' ); 17 } 18 } 19 } ); 20 21 /** 22 * Notices in cart 23 */ 24 $( document.body ).on( 'wcs_updated_cart', function() { 25 let noticesEl = $( '#wcs-notices-pending' ); 26 27 if ( noticesEl.length > 0 ) { 28 // Clear existing notices 29 $( '#wcs-notices' ).remove(); 30 31 let shippingMethods = $( '.woocommerce-shipping-totals ul.woocommerce-shipping-methods' ); 32 33 if ( shippingMethods.length > 0 ) { 34 shippingMethods.after( noticesEl ); 35 noticesEl.css( 'display', 'block' ).attr( 'id', 'wcs-notices' ); 36 } 37 } 38 } ); 39 $( document.body ).trigger( 'wcs_updated_cart' ); 40 $( document.body ).on( 'updated_cart_totals', function() { 41 $( document.body ).trigger( 'wcs_updated_cart' ); 42 } ); 43 44 /** 45 * Trigger checkout update if some field that is used 46 * for conditions is updated. Some fields such as email 47 * don't trigger checkout update by default 48 */ 49 function wcsTriggerCheckoutUpdate() { 50 if ( typeof conditional_shipping_settings != 'undefined' ) { 51 $.each( conditional_shipping_settings.trigger_fields, function( index, value ) { 52 $( document.body ).on( 'change', 'input[name="' + value + '"]', function() { 53 $( document.body ).trigger( 'update_checkout' ); 54 } ); 55 56 if ( value.indexOf('shipping_') !== -1 ) { 57 var billingValue = value.replace( 'shipping', 'billing' ); 58 if ( $.inArray( billingValue, conditional_shipping_settings.trigger_fields ) === -1 ) { 59 $( document.body ).on( 'change', 'input[name="' + billingValue + '"]', function() { 60 $( document.body ).trigger( 'update_checkout' ); 61 } ); 62 } 63 } 64 } ); 65 } 66 } 67 wcsTriggerCheckoutUpdate(); 68});
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.