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:	ecommercehints.com

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 }
WooCommerce Conversion Rate Optimisation (CRO) eBook
100 WooCommerce Conversion Rate Optimisation Tips

Leave a Reply

If you are going to write code in the comments, please wrap it between code tags.

Your email address will not be published. Required fields are marked *

Other Recent Guides

Subscribe To Emails

Get exclusive WooCommerce tips that I only share with email subscribers

Join hundreds of other subscribers