Good morning everybody,
I'm trying to introduce a fiscal code verification during my checkout. The verification is similar to what Wordpress does with email.
I created a similar "email_exists()" function to check if the fiscal code in the order already exists and then I put a function to give a warning if this fiscal code exists.
Here's the code:
function cf_exists( $order_cf ) {
$order_cf = $order->billing_address_2;
$user = get_user_by( 'fiscalcode', $billing_address_2 );
if ( $user ) {
$user_id = $user->ID;
} else {
$user_id = false;
function cf_check(){
if ( cf_exists( $order_cf ) ) {
return new WP_Error( 'registration-error-fc-exists', __( 'An account is already registered with your fiscal code. Please login.', 'woocommerce' ) );
}
As usual, Wordpress breaks itself and I don't understand what I'm missing. Hope to get some help, thanks in advance for your time!