Hi, great news thanks a lot!
I did some tests and I think one situation remains out:
If I add the field to the registration form, disable the validity check and set the field as “required”, this is mandatory in the checkout correctly, but not in the registration form, although the field label has the indication as required. By entering only the username and password, without entering the vat number, no error is given and the account is created anyway. I solved it with this code:
// registration Field validation
function fn_woo_account_registration_field_validation(
$errors,
$username,
$email
) {
if (isset($_POST["billing_eu_vat_number"]) && empty($_POST["billing_eu_vat_number"])) {
$errors->add(
"vat_number_error",
__("<strong>VAT Number</strong> is mandatory!", "eu-vat-for-woocommerce")
);
}
return $errors;
}
add_filter("woocommerce_registration_errors","fn_woo_account_registration_field_validation",10,3);