Skip to content

Instantly share code, notes, and snippets.

@danichim
Last active February 20, 2021 21:51
Show Gist options
  • Save danichim/63f51f41273bbbf898ea1185a4192ee1 to your computer and use it in GitHub Desktop.
Save danichim/63f51f41273bbbf898ea1185a4192ee1 to your computer and use it in GitHub Desktop.
check number and country at checkout
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'] )) && $_POST['billing_country'] == 'RO') {
wc_add_notice( "<strong>Telefon</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