Woocommerce order total ajax update on country change
This is the simple solution for apply ajax update on Woocommerce checkout order total based on country change. Add this code to your theme functions php file.
//Creative Tweets-- add_action('wp_footer', 'billing_country_update_checkout', 50); function billing_country_update_checkout() { if ( ! is_checkout() ) return; ?> <script type="text/javascript"> jQuery(function($){ $('select#billing_country, select#shipping_country').on( 'change', function (){ var t = { updateTimer: !1, dirtyInput: !1, reset_update_checkout_timer: function() { clearTimeout(t.updateTimer) }, trigger_update_checkout: function() { t.reset_update_checkout_timer(), t.dirtyInput = !1, $(document.body).trigger("update_checkout") } }; $(document.body).trigger('update_checkout'); console.log('Event: update_checkout'); }); }); </script> <?php }
ajax update on Woocommerce order total based on state change
Add this code to your theme functions php file for apply ajax update on Woocommerce checkout order total based on state change.
//----Creative Tweets add_action('wp_footer', 'billing_country_update_checkout', 50); function billing_country_update_checkout() { if ( ! is_checkout() ) return; ?> <script type="text/javascript"> jQuery(function($){ $('select#billing_state, select#shipping_state').on( 'change', function (){ var t = { updateTimer: !1, dirtyInput: !1, reset_update_checkout_timer: function() { clearTimeout(t.updateTimer) }, trigger_update_checkout: function() { t.reset_update_checkout_timer(), t.dirtyInput = !1, $(document.body).trigger("update_checkout") } }; $(document.body).trigger('update_checkout'); console.log('Event: update_checkout'); }); }); </script> <?php }