Check Greek phone numbers at checkout
For customers in Greece, the checkout accepts only valid Greek phone numbers: 10 digits starting with 2 (landline) or 69 (mobile), with or without +30.
<?php
add_action(
'woocommerce_after_checkout_validation',
static function ( $data, $errors ) {
if ( 'GR' !== ( $data['billing_country'] ?? '' ) || '' === (string) ( $data['billing_phone'] ?? '' ) ) {
return;
}
$phone = preg_replace( '/[\s\-().]/', '', (string) $data['billing_phone'] );
$phone = preg_replace( '/^(\+30|0030)/', '', $phone );
if ( ! preg_match( '/^(2\d{9}|69\d{8})$/', $phone ) ) {
$errors->add( 'validation', 'Ο αριθμός τηλεφώνου δεν είναι έγκυρος. Γράψτε 10 ψηφία, π.χ. 6912345678 ή 2310123456.' );
}
},
10,
2
);
Good to know
For the classic checkout.
In these packs
- Greek e-shop: For shops in Greece: receipt or invoice with a checked VAT number (ΑΦΜ), Greek phone and postcode checks, a cash on delivery fee, and greeklish addresses.