I am using WooCommerce in my WordPress web site. The customers billing and shipping details are populated by default on checkout page. I want that the country will not be set by default. Instead it will asked to select country even if user is logged in.
Any suggestions? What I should do in order to achieve this?
Update (Since WooCommerce 3)
This are the woocommerce hooks and code to be used for this purpose for country (and optionally state):
Or even shorter:
Code goes in functions.php file of the active child theme (or active theme). Tested and works.
Related: WooCommerce: Set country by default in checkout page for unlogged users
It’s worth noting that the most current method for achieving this will likely always be viewable in the Woocommerce documentation, here.
It’s also worth noting it may be undesirable to remove the default country for existing (logged-in) customers. At least on sites that allow customers to have a customer account. For those customers the address fields will be automatically filled out for them, and if you remove the default country for all uses, then their address will be filled out, except that the country will be missing.
With that in mind, as of January 2022, I would suggest this code as a useful way to achieve what the OP requested:
This is a slight variation of what’s conveyed in the WC documentation, which was addressing how to change what the default country is set to. In this case we’re setting it to
Null
.Those function has been depreciated
Tested in WooCommerce Version 4.5.2
I just wanted to let you know that I have tackled the same issue.
I have written a small plugin here: https://github.com/TakesTheBiscuit/woocommerce_set_country
The primary user experience fix here is to provide a select box to users before they get to the cart or checkout – that way you can tailor your user experience elsewhere for their session – such as custom pricing, shipping rates, taxes etc.
Whilst writing the plugin I also found that admin (who you are usually logged in as a site owner) already often has a country set, so to test the functionality we want to exclude admins from having their default country.
Final thought from me; You’ll also find the shipping calculator is not able to pick up these default countries, frustratingly – so you’ll need to work around that too.