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.
WooCommerce Conversion Rate Optimisation (CRO) eBook
100 WooCommerce Conversion Rate Optimisation Tips

2 Responses

    1. Hey Roberto,
      There sure is – check out this guide (WooCommerce Custom Text Field On Registration Form)
      You’ll want to remove the function which saves the email as user meta and add a conditional if statement to make sure the two fields match (then just update the error message to whatever you please).
      If you still have trouble, contact us and we’ll send you a quote for a custom snippet to meet your needs 🙂

Leave a Reply

If you are going to write code in the comments, please wrap it between code tags.

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

Other Recent Guides

Subscribe To Emails

Get exclusive WooCommerce tips that I only share with email subscribers

Join hundreds of other subscribers