如何在wooccommerce结账页面中创建从"05〃;。并且应该是最大的10位数字。但是,空格不应该包含在这10位数字中。
我有答案,它正在工作:
// Limit Woocommerce phone field to 10 digits number || Mdsourov || sourov.com
add_action('woocommerce_checkout_process', 'njengah_custom_checkout_field_process');
function njengah_custom_checkout_field_process() {
global $woocommerce;
// Check if set, if its not set add an error. This one is only requite for companies
$is_correct = preg_match('/^05[0-9]{8}$/', $_POST['billing_phone']);
if ( $_POST['billing_phone'] && !$is_correct) {
wc_add_notice( "Incorrect Phone Number! Please enter valid 10 digits phone number that start with 05" ,'error' );
}
}