In woocommerce already the shipping country in restricted to IN
On checkout the default value of Country, state & city is set
I want to do that same in my-account/edit-address/ only in shipping address
tried using this code but its not working
add_filter( 'woocommerce_shipping_fields' , 'default_shipping_address' );
function default_shipping_address( $fields ) {
$fields['shipping_city']['default'] = 'Mumbai';
$fields['shipping_state']['default'] = 'Maharashtra';
return $fields;
}
this is not working let me know what’s wrong or is there any other way to do this?
2
Answers
You can use the address hook.
You are pretty near… As Shipping State value in WooCommerce is a state code, you need to replace ‘Maharashtra’ with ‘MH’ (For India) as follows:
Code goes in functions.php file of the active child theme (or active theme). Tested and works.
Alternative: If it really doesn’t work for you, you can try to use the following: