That action helps to make fields non-required
add_filter( 'woocommerce_checkout_fields', 'unrequire_checkout_fields' );
function unrequire_checkout_fields( $fields ) {
$fields['billing']['billing_company']['required'] = false;
$fields['billing']['billing_city']['required'] = false;
$fields['billing']['billing_postcode']['required'] = false;
$fields['billing']['billing_country']['required'] = false;
$fields['billing']['billing_state']['required'] = false;
$fields['billing']['billing_address_1']['required'] = false;
$fields['billing']['billing_address_2']['required'] = false;
return $fields;
}
But it works only with css
#billing_country_field, #billing_address_1_field, #billing_address_2_field,#billing_state_field,#billing_last_name_field,#billing_postcode_field,#billing_company_field {
display: none !important; }
I thinks that's not the best decision. It has to be like that
add_filter('woocommerce_checkout_fields','remove_checkout_fields');
function remove_checkout_fields($fields){
unset($fields['billing']['billing_first_name']);
unset($fields['billing']['billing_last_name']);
unset($fields['billing']['billing_address_1']);
unset($fields['billing']['billing_address_2']);
unset($fields['billing']['billing_city']);
unset($fields['billing']['billing_postcode']);
unset($fields['billing']['billing_country']);
unset($fields['billing']['billing_state']);
return $fields;
}
But when I'm adding exactly that code, it requires address and says that the pay method(native local pickup) is wrong. Without that code and with css all works fine. Maybe someone had the same problem and already solved it? Without plugins if possible.