Limit Phone Number Digits for certain countries
-
Hi,
I am using this code to limit phone numbers to 11 digits for DPD shipping, however, other countries outside of the UK need more digits… I can’t seem to tell the field to look out for the country and if GB then, and only then, run the rule…
My working code so far…
// Limit Woocommerce phone field to 11 digits number add_action('woocommerce_checkout_process', 'my_custom_checkout_field_process'); function my_custom_checkout_field_process() { global $woocommerce; // Check if set, if its not set add an error. This one is only requite for companies if ( ! (preg_match('/^[0-9]{11}$/D', $_POST['billing_phone'] ))){ wc_add_notice( "Please enter valid 11 digit phone number." ,'error' ); } } //FINISH LIMIT PHONE NUMBER TO 11 DIGITS
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Limit Phone Number Digits for certain countries’ is closed to new replies.