Huisnummer check in webshop WooCommerce

Heb je regelmatig dat bezoekers van je webshop vergeten hun huisnummer achter het adres te plaatsen? Met deze code in je functions.php van je thema of de plugin Code Snippets is dit verleden tijd, je bouwt een check in op huisnummer.

add_action(‘woocommerce_checkout_process’, ‘custom_validation_process’);

function custom_validation_process()
{
global $woocommerce;

if(isset($_POST[‘billing_address_1’]) and $_POST[‘billing_address_1’] != ”)
{
if (!preg_match(‘/([0-9]+)/Uis’, $_POST[‘billing_address_1’]))
{
if(function_exists(‘wc_add_notice’))
wc_add_notice( __(‘Oeps, vergeet niet je huisnummer in te vullen in het adresveld.’), ‘error’ );
else
$woocommerce->add_error( __(‘Oops, vergeet niet je huisnummer in te vullen in het adresveld.’) );
}
}

if(isset($_POST[‘ship_to_different_address’]))
{
if(isset($_POST[‘shipping_address_1’]) and $_POST[‘shipping_address_1’] != ”)
{
if (!preg_match(‘/([0-9]+)/Uis’, $_POST[‘shipping_address_1’]))
{
if(function_exists(‘wc_add_notice’))
wc_add_notice( __(‘Oops, vergeet niet je huisnummer in te vullen in het adresveld.’), ‘error’ );
else
$woocommerce->add_error( __(‘Oops, vergeet niet je huisnummer in te vullen in het adresveld.’) );
}
}
}
}

Wil jij gratis WordPress tips in je inbox ontvangen?

Wij sturen maximaal 2 e-mails per maand. Beloofd!

Voornaam
Dit veld is bedoeld voor validatiedoeleinden en moet niet worden gewijzigd.