Created
November 7, 2018 20:26
-
-
Save danichim/8bf1c05322daf2528d1e918cbfc332b5 to your computer and use it in GitHub Desktop.
validate length billing phone and shipping phone woocommerce
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action('woocommerce_checkout_process', 'check_phone_number_length'); | |
function check_phone_number_length() { | |
global $woocommerce; | |
if ( ! (preg_match('/^[0-9]{10}$/D', $_POST['billing_phone'] ))){ | |
wc_add_notice( "<strong>Telefon facturare</strong> Număr incorect ! Trebuie să conțină 10 cifre" ,'error' ); | |
} | |
if (isset($_POST['shipping_phone']) && !empty($_POST['shipping_phone'])) { | |
if ( ! (preg_match('/^[0-9]{10}$/D', $_POST['shipping_phone'] ))){ | |
wc_add_notice( "<strong>Telefon livrare</strong> Număr incorect ! Trebuie să conțină 10 cifre" ,'error' ); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment