Email confirmation field in WooCommerce

woo expert

You will agree with me that one of the most common mistakes made by customers of an online store, and in almost all websites, is when it comes to correctly enter an email.

And of course, then we know what happens?

  • They do not receive the account creation confirmation.
  • They do not receive the order confirmations
  • They don’t receive the shipment tracking
  • They don’t receive the invoices
  • They don’t receive ANYTHING … because they put the email address wrong!
relax

It is a reality, that the customer at the end of the purchase is more concerned about putting the bank details or that the order is what he/she wanted than to correctly fill in the fields (mandatory and essential) to manage your order.

And they make some mistakes.

Well, a great way to avoid these mistakes when entering the email is to add another field, for a double-check, and if they make a mistake when entering the email again, an error will appear, until they get it right in both fields (or wrong in both fields, which I have also seen).

A simple and quick way to add this additional email verification field on the checkout page would be through this code:

/* Field to confirm your email at checkout */
add_filter( 'woocommerce_checkout_fields' , 'wphelp_confirm_email_checkout' );
function wphelp_confirm_email_checkout( $fields ) {
$fields['billing']['billing_email']['class'] = array( 'form-row-first' );
$fields['billing']['billing_em_ver'] = array(
'label' => 'Confirm your email address',
'required' => true,
'class' => array( 'form-row-last' ),
'clear' => true,
'priority' => 999,
);
return $fields;
}
// Error message if they are different
add_action('woocommerce_checkout_process', 'wphelp_check_second_email');
function wphelp_check_second_email() { 
$email1 = $_POST['billing_email'];
$email2 = $_POST['billing_em_ver'];
if ( $email2 !== $email1 ) {
wc_add_notice( 'Your email addresses do not match', 'error' );
}
}Code language: PHP (php)

You can add this code to the functions.php file of the active theme or to your own customizations plugin.

You will go from this:

default checkout

To this:

checkout with email confirmation

Easy.

No more problems, no one will put their email address wrong twice right?

How useful was this post?

Click on a smiley to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.

As you found this post useful...

Follow us on social media!

About The Author

2 thoughts on “Email confirmation field in WooCommerce”

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top