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