WooCommerce Update Checkout Totals On Billing State/County Change


There are no pre-requisites in order for you to be able to implement this solution.

How To Implement This Solution?

Simply copy the pre-coded solution to your active theme’s functions.php or preferably the Code Snippets Plugin.

About This Solution

Are you writing a custom snippet which makes changes to the order totals based on the billing county / state?

Perhaps your snippet adds a fee to the order depending on the billing state / county but the totals are not refreshed in the “Your order” section of the checkout.

This snippet will update the checkout totals when the billing state / county is selected on the checkout.

 * Snippet Name:	WooCommerce Update Checkout Totals On Billing Sate / County Change
 * Snippet Author:

add_action( 'wp_footer', 'ecommercehints_update_checkout_totals' );
function ecommercehints_update_checkout_totals() { ?>
	jQuery( function( $ ) {
	$( 'form.checkout' ).on( 'change', 'select[name^="billing_state"]', function() {
		$( 'body' ).trigger( 'update_checkout' );
<?php }

100 WooCommerce Conversion Rate Optimisation Tips

This field is for validation purposes and should be left unchanged.

Let’s collaborate!

Need to outsource WordPress development?

Join forces with UnlimitedWP for an outsourced white label web development service you can truly rely on.

First Timer Here?

Sign up to receive 20% off on your first month with us.