Solution:
You should need to use woocommerce_default_address_fields
filter hook instead as explained here.
The replacement code:
// Billing and shipping addresses fields
add_filter( 'woocommerce_default_address_fields' , 'filter_default_address_fields', 20, 1 );
function filter_default_address_fields( $address_fields ) {
// Only on checkout page
if( ! is_checkout() ) return $address_fields;
// All field keys in this array
$key_fields = array('country','first_name','last_name','company','address_1','address_2','city','state','postcode');
// Loop through each address fields (billing and shipping)
foreach( $key_fields as $key_field )
$address_fields[$key_field]['required'] = false;
return $address_fields;
}
As billing email and phone are already required by default, if you want them to be not required, you should need this additional code:
// For billing email and phone - Make them not required
add_filter( 'woocommerce_billing_fields', 'filter_billing_fields', 20, 1 );
function filter_billing_fields( $billing_fields ) {
// Only on checkout page
if( ! is_checkout() ) return $billing_fields;
$billing_fields['billing_phone']['required'] = false;
$billing_fields['billing_email']['required'] = false;
return $billing_fields;
}
All code goes in function.php file of your active child theme (or active theme). Tested and works.