Checkout

WooCommerce Checkout Confirm Email Address

WooCommerce checkout form showing confirm you email address field

Pre-Requisites

There are no pre-requisites in order for you to be able to implement this solution.

How To Implement This Solution?

Simply copy the pre-coded solution to your active theme’s functions.php or preferably the Code Snippets Plugin.

About This Solution

This guide shows you how you can introduce a new required checkout billing field which asks the user to confirm their email address. This sort of solution prevents confirmation emails not being received or even going to the wrong recipient. Specifically, this guide makes the existing billing email field half width and injects a new field next to it. If the two email fields do not match, the user cannot checkout and an error message appears letting the user know the two email addresses do not match.

/**
 * Snippet Name:	WooCommerce checkout confirm email address
 * Snippet Author:	ecommercehints.com
 */

add_filter( 'woocommerce_checkout_fields' , 'ecommercehints_confirm_email_checkout_field' );
function ecommercehints_confirm_email_checkout_field( $fields ) {

$fields['billing']['billing_email']['class'] = array( 'form-row-first' ); // Make billing email field half width
$fields['billing']['billing_confirm_email'] = array(
    'label' => 'Confirm Your Email Address',
    'required' => true,
    'class' => array( 'form-row-last' ), // Make email confirmation field half width
    'priority' => 999, // Display field at the end of the checkout form
	'description' => '<small>We don\'t want to send the wrong person your email confirmation!</small>',
);
return $fields;
}

add_action('woocommerce_checkout_process', 'ecommercehints_equal_emails_validation');
function ecommercehints_equal_emails_validation() {
    $email_address = $_POST['billing_email'];
    $confirm_email_address = $_POST['billing_confirm_email'];
    if ( $email_address !== $confirm_email_address ) {
        wc_add_notice( 'Your email addresses don\'t match', 'error' );
    }
}

Snippet Benefits

  • Ensure customers enter the correct email address to receive confirmation emails.
  • Clean your mailing list data which accurate email addresses at the data capture level.

100 WooCommerce Conversion Rate Optimisation Tips

This field is for validation purposes and should be left unchanged.

Let’s collaborate!

Need to outsource WordPress development?

Join forces with UnlimitedWP for an outsourced white label web development service you can truly rely on.

First Timer Here?

Sign up to receive 20% off on your first month with us.

26027
WELCOME OFFER