2
votes

I have a problem with WooCommerce billing phone validation. I installed YITH checkout manager for edit checkout fields and delete a phone number field, but when I try going to the next step I see the error for phone validation! Also I added below code in my functions, but there was no change. help me to fix this error.

add_filter('woocommerce_checkout_fields', 'no_phone_validation')

function no_phone_validation($woo_checkout_fields_array)
{
    unset($woo_checkout_fields_array['billing']['billing_phone']['validate']);
    return $woo_checkout_fields_array;
}
2

2 Answers

1
votes

You should better try before everything else to make this field optional (not required) to avoid the field validation:

add_filter('woocommerce_billing_fields', 'no_billing_phone_validation' );
function no_billing_phone_validation( $fields ) {
    $fields['billing_phone']['required'] = false;
    return $fields;
}

Code goes in functions.php file of your active child theme (or active theme). It could works.

0
votes

You should try below code. It worked for me and I am sure that it'll work for you as well

add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );
function custom_override_checkout_fields( $fields ) {
    unset($fields['billing']['billing_phone']);
    return $fields;
}