How to change the customer’s default country/state in WooCommerce

There is a setting in WooCommerce that allows a merchant to choose which country/state their shoppers see when they first arrive at the checkout. This defaults to the store’s country and state, so if your store is located in Arizona, USA, then your shoppers will also see that.

It is also possible to try to geolocate your customers.

In some instances, it may be desirable to modify the value even further, for example if your store is based in Arizona, USA, but you do business with shoppers all over the States, you might want to remove the state from the default address

To do this you can use the woocommerce_customer_default_location_array hook.

add_filter(
	'woocommerce_customer_default_location_array',
	function( $location ) {
		return [
			'country' => 'US',
			'state'   => ''
		];
	}
);

Leave a Reply