Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter citycentertv

    (@citycentertv)

    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);
    Thread Starter citycentertv

    (@citycentertv)

    Hi, thanks for the reply. Yes, I confirm, actually by setting it as optional you can proceed with an incorrect VAT number.
    However, since I would still like the insertion of a VAT number to be mandatory, even if not validated, is the only way to proceed by manually modifying the form to make the field mandatory?

Viewing 2 replies - 1 through 2 (of 2 total)