// Custom validation for Billing Phone checkout field add_action('woocommerce_checkout_process', 'custom_validate_billing_phone'); function custom_validate_billing_phone() { $ff ="/^(?:(?:(\+?972|\(\+?972\)|\+?\(972\))(?:\s|\.|-)?([1-9]\d?))|(0[23489]{1})|(0[57]{1}[0-9]))(?:\s|\.|-)?([^0\D]{1}\d{2}(?:\s|\.|-)?\d{4})$/"; $is_correct = preg_match('/^(?:(?:(\+?972|\(\+?972\)|\+?\(972\))(?:\s|\.|-)?([1-9]\d?))|(0[23489]{1})|(0[57]{1}[0-9]))(?:\s|\.|-)?([^0\D]{1}\d{2}(?:\s|\.|-)?\d{4})$/', $_POST['billing_phone']); if ( $_POST['billing_phone'] && !$is_correct) { wc_add_notice( __( 'יש להזין מספר טלפון ישראלי תקין' ), 'error' ); } }