I'd like to change the default country on the cart page to none, i.e. to have "Select a country…" appear as the default in the drop-down list of countries.
I've looked at this WooCommerce Docs snippet which uses the
default_checkout_country filter but it only seems to apply to the checkout page (and not the cart page), as its title says. I also tested this by surrounding the
apply_filters('default_checkout_country', ... in the files where they appear with
echo statements and they don't appear anywhere in the generated markup for the cart page.
As we are using PayPal Express Checkout we don't use the WooCommerce built-in checkout page so it appears that the above mentioned snippet doesn't apply and another solution is needed.
My next step was to look into
woocommerce/templates/cart/shipping-calculator.php where the country option list is generated on the cart page. There's a call to
$woocommerce->customer->get_shipping_country(). That function in
woocommerce/classes/class-wc-customer.php simply picks up the
$_SESSION['customer']['shipping_country'] variables. The only place those variables are set is in the function
set_shipping_to_base() in the same file and the only place that function is (conditionally) called is in
woocommerce/shortcodes/shortcode-cart.php which I assume generates the cart from the shortcode used on the autogenerated cart page. I added a
echo statement to the block in that file where that function is called but nothing appeared in the markup, so I got stuck there.
The above investigation seems however to be somewhat of a red herring as the above mentioned session variables seem to actually be set by the Base Country/Region setting on the General tab, as it would vary accordingly when the
$_SESSION variable got printed in a browser where cookies and cache had been previously deleted. So I'm kind of stuck here too. I'd like the Base Country/Region setting to remain the country set, but still have no default country unless the visitor actually has selected it.