I would like add my own regular expression for validating the phone number. In my class-wc-validation.php
I have changed the regular expression to my requiremen
I have not seen your code that hooks these up to the woocommerce checkout flow. please check their documentation on
woocommerce_checkout_process
and woocommerce_checkout_order_processed
But in your case, I highly suggest that you hook it up on woocommerce_checkout_process
so put these codes below on your functions.php on your theme, or you create your own woocommerce plugins, and put it in the bootstrap code.
add_action('woocommerce_checkout_process', 'is_phone');
function is_phone() {
$phone_number = $_POST['---your-phone-field-name---'];
// your function's body above, and if error, call this wc_add_notice
wc_add_notice( __( 'Your phone number is wrong.' ), 'error' );
}