Solution:
I have done this:
add_filter( 'woocommerce_checkout_fields' , 'company_checkbox_and_new_checkout_fields_1', 9999 );
function company_checkbox_and_new_checkout_fields_1( $fields ) {
if (isset($_POST['buy_on_company'])) {
$fields['billing']['billing_name']['required'] = false;
} else {
$fields['billing']['billing_name']['required'] = true;
}
return $fields;
}
Now it doesn’t ask for billing name field.