Remove Country from Checkout
-
Hello,
I’ve managed to remove some fields from the checkout via two functions:
/*Make fields from Checkout optional*/
add_filter( 'woocommerce_default_address_fields' , 'custom_override_default_address_fields' );
function custom_override_default_address_fields( $address_fields ) {
$address_fields['company']['required'] = false;
$address_fields['country']['required'] = false;
$address_fields['address_2']['required'] = false;
$address_fields['city']['required'] = false;
$address_fields['postcode']['required'] = false;
return $address_fields;
}
/* Remove fields from Checkout */
add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );
function custom_override_checkout_fields( $fields ) {
unset($fields['billing']['billing_company']);
//unset($fields['billing']['billing_country']);
unset($fields['billing']['billing_address_2']);
unset($fields['billing']['billing_city']);
unset($fields['billing']['billing_postcode']);
return $fields;
}
Nevertheless, when I try to buy something, I get an error. If remove the “unset” for country, it works.
How can I fix this? I only ship in one contry (which is default in WooCommerce config and appears as default).
Thanks
Hello,
This field comes with WooCommerce plugin, and not with our theme. Sorry, but additional customization of third party plugins is out of our theme support scope.
Regards
Thanks. At least, do you have any clue where this goes? Maybe some docs you remember. So far nothing.
Thanks!
We suggest you to try this plugin to manage your checkout fields https://wordpress.org/plugins/woocommerce-checkout-manager/