WooCommerce: Add “Confirm Email Address” Field @ Checkout
A correct email address is worth a thousand dollars, some ecommerce expert would say ๐ So, you don’t want your WooCommerce checkout visitors to mess up with that, do you?
What about adding an “Email Verification” field? In this way, we can make sure they double check their entry – and also show an error message in case they don’t match!
Let’s see how I implemented this for a freelancing client of mine – I’m sure you will be grateful!
PHP Snippet: Add “Confirm Email Address” Field @ WooCommerce Checkout
/**
* @snippet Add "Confirm Email Address" Field @ WooCommerce Checkout
* @how-to Get CustomizeWoo.com FREE
* @author Rodolfo Melogli
* @testedwith WooCommerce 7
* @community https://businessbloomer.com/club/
*/
// ---------------------------------
// 1) Make original email field half width
// 2) Add new confirm email field
add_filter( 'woocommerce_checkout_fields' , 'bbloomer_add_email_verification_field_checkout' );
function bbloomer_add_email_verification_field_checkout( $fields ) {
$fields['billing']['billing_email']['class'] = array( 'form-row-first' );
$fields['billing']['billing_em_ver'] = array(
'label' => 'Confirm mail Address',
'required' => true,
'class' => array( 'form-row-last' ),
'clear' => true,
'priority' => 999,
);
return $fields;
}
// ---------------------------------
// 3) Generate error message if field values are different
add_action( 'woocommerce_checkout_process', 'bbloomer_matching_email_addresses' );
function bbloomer_matching_email_addresses() {
$email1 = $_POST['billing_email'];
$email2 = $_POST['billing_em_ver'];
if ( $email2 !== $email1 ) {
wc_add_notice( 'Your email addresses do not match', 'error' );
}
}
This code still works, unless you report otherwise. To exclude conflicts, temporarily switch to the Storefront theme, disable all plugins except WooCommerce, and test the snippet again: WooCommerce troubleshooting 101
Related content
WooCommerce: Cart and Checkout on the Same Page This is your ultimate guide – complete with shortcodes, snippets and workarounds – to completely skip the Cart page and have both cart table and checkout form on the same (Checkout) page. But first… why’d you want to do this? Well, if you sell high ticket products (i.e. on average, you sell no more than […]
WooCommerce: Disable Payment Method If Product Category @ Cart Today we take a look at the WooCommerce Checkout and specifically at how to disable a payment gateway (e.g. PayPal) if a specific product category is in the Cart. There are two tasks to code in this case: (1) based on all the products in the Cart, calculate the list of product categories in the […]
WooCommerce: Add Privacy Policy Checkbox @ Checkout Here’s a snippet regarding the checkout page. If you’ve been affected by GDPR, you will know you now need users to give you Privacy Policy consent. Or, you might need customer to acknowledge special shipping requirements for example. So, how do we display an additional tick box on the Checkout page (together with the existing […]
WooCommerce: Redirect to Custom Thank you Page How can you redirect customers to a beautifully looking, custom, thank you page? Thankfully you can add some PHP code to your functions.php or install a simple plugin and define a redirect to a custom WordPress page (as opposed to the default order-received endpoint). This is a great way for you to add specific up-sells, […]
WooCommerce: Disable Payment Gateway by Country You might want to disable PayPal for non-local customers or enable a specific gateway for only one country… Either way, this is a very common requirement for all of those who trade internationally. Here’s a simple snippet you can further customize to achieve your objective. Simply pick the payment gateway “slug” you want to disable/enable […]
Rodolfo Melogli
Business Bloomer Founder
Author, WooCommerce expert and WordCamp speaker, Rodolfo has worked as an independent WooCommerce freelancer since 2011. His goal is to help entrepreneurs and developers overcome their WooCommerce nightmares. Rodolfo loves travelling, chasing tennis & soccer balls and, of course, wood fired oven pizza. Follow @rmelogli
109 thoughts on “WooCommerce: Add “Confirm Email Address” Field @ Checkout”
This snippet works like a charm under WordPress 6.5.5 and woocommerce 9.1.0 as of today 12/07/2024 and additionnaly I’m using Breakdance Builder 2.0.0-rc.1
Thank you so much for this beautiful simple snippet !!! You save us with this !
OK anyone able to help as I’m a total novice. I have the code on site and the confirm Box is there and working. However, I ask name then email address and a few other questions but the confirm email address option is at the very bottom. How do I get it beside the other enter email at top?
This is an excellent snippet, but unfortunately I have found it raises a problem when used with the Saved Addresses for WooCommerce plugin, as I have just had a customer fail to check out using a saved address with the error “billing confirm mail address is a required field”.
It seems like the confirmation field is not present in previously saved addresses, and I will contact you in BloomerArmada to work out next steps.
Thanks.
Thank you! Yeah I guess the snippet will need to be tweaked a little in order to be compatible with the extension – feel free to email me the plugin ZIP and I can take a look
Hi Rubb, you can do so with some custom JS, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!
I’ve just noticed a small problem; when using an iPad this extra email field forces the email address to start with a capital first letter and this is obviously causing problems as it then doesn’t recognise the email addresses to be identical โ unless you go back and correct the first written letter that is; which some won’t think to do.
Hello Sven, thanks so much for your comment! Yes, this is definitely possible via JS, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!
Hi there,
The functionality of the code seems to be limited when it comes to off-site payments. If the payment (off-site) fails, the customer is redirected back to the checkout page, where he has to fill out the email confirmation field again. Does anyone have an idea, how this could be solved?
Hello Johannes! Which payment gateway are you referring to? PayPal, for example, redirects back to the Cart as long as I see, so there’s no problem there
Hi Rodolfo,
Thanks for your feedback!
It’s a Swiss payment gateway (Postfinance) which redirects back to the checkout page, if the payment fails (or is cancelled bei the customer).
But actually I think it’s the same with PayPal: if the user is redirected back to the cart page after the payment has failed (or was cancelled by the user) and he proceeds to the checkout page again, he has to confirm his email address a second time, while the rest of the fields are prefilled. So it works in general, but it’s a little inconvenient for the customer if he has to confirm his email twice. But maybe this behaviour only occurs with our payment gateway?
Thanks for the clarification. Yes, this is due to Postfinance and the way it works, so I’m afraid this is custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!
It does not work with Paypal where paypal has to come back to the site to confirm order. That extra step always results in a false “emails don’t match error”
Thank you for this – just what I was looking for.
I changed it slightly so it says confirm Email address, rather than mail – and was really chuffed with myself!
Works correct. But is it possible to validate when e-mailadres is with starting capital and confirmation not? Now you get an error but the e-mailadress works fine with capitals or not.
Hello Kees, thanks so much for your comment! Yes, this is definitely possible, but Iโm afraid itโs custom work. If youโd like to get a quote, feel free to contact me here. Thanks a lot for your understanding!
We have made the following changes in the code to make sure customer does not get error even if they add a space or enter the email address in capital in any of the field.
add_action('woocommerce_checkout_process', 'bbloomer_matching_email_addresses');
function bbloomer_matching_email_addresses() {
$email1 = $_POST['billing_email'];
$email2 = $_POST['billing_em_ver'];
if ( strtolower (trim($email2)) !== strtolower(trim($email1) )) {
wc_add_notice( 'Your email addresses do not match', 'error' );
}
}
It works with Paypal, after adding comment from JD Farrell
It does work with Stripe credit card payments.
It doesn’t work for me with Stripe > Google Pay (and probably apple pay, still testing)
Google Pay doesn’t require you to fill any fields.
User clicks on pay now in Cart, user confirms payment in Android Pay, user is returned to checkout page with error that email adresses do not match, the payment never goes through.
There are ofc no email confirm fields to fill out on google pay, I guess their payment gateway posts back an email value, but the form fails.
Not sure how this can be avoided
Hi Simon, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!
Hi Richard, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!
Hey! Love the blog, I actually encountered an issue with the way validation was working for this snippet. It was rather confusing since PayPal would still open and let them process their information.
I followed woo source code to see how validation works. Changing the hook and adding the $error to the existing $error variable made it validate like the rest (various billing validation etc)
// 3) Generate error message if field values are different
add_action('woocommerce_after_checkout_validation', 'bbloomer_matching_email_addresses',10, 2);
function bbloomer_matching_email_addresses($data, $errors) {
$email1 = $_POST['billing_email'];
$email2 = $_POST['billing_em_ver'];
if ($email2 !== $email1) {
$errors->add( 'validation', __( 'Your email addresses do not match. (Note: is case sensitive)', 'woocommerce' ) );
}
}
The above changes now validate before PayPal or any order processing is done. The issue was, the money would get validated from paypal and get placed on-hold from bank which would eventually get returned since never processed by PayPal.
Thank you,
it was working well until I encountered Stripe Google Pay / Apple Pay payments
I found the following workaround:
// 3) Generate error message if field values are different only if not using stripe / android pay / apple pay
add_action('woocommerce_after_checkout_validation', 'bbloomer_matching_email_addresses',10, 2);
function bbloomer_matching_email_addresses($data, $errors) {
$email1 = $_POST['billing_email'];
$email2 = $_POST['billing_em_ver'];
if ($email2 !== $email1) {
if (!($_POST['payment_method'] == 'stripe' and in_array($_POST['payment_request_type'], array('payment_request_api','apple_pay')))) {
$errors->add( 'validation', __( 'Your E-Mails do not match.', 'woocommerce' ) );
}
}
}
after that android pay was still complaining that billing_em_ver field is required, and I was not able to unset it in the error handling,
so I just set [‘billing_em_ver’] required from Step2 to false
I guess the “email fields are different” is a sufficient error anyway
One problem I ran into. When a customer checks out using PayPal (customer clicks the paypal button before they input their email) they automatically get redirected to the final checkout page. When this happens, Paypal fills out their name and email account for them so when they click the final purchase button, it says their “emails do not match” but there is no option to confirm their email since Paypal redirected them.
Not sure if that makes sense, but it basically removes a customers ability to checkout with Paypal if they don’t pre-fill their information which is a big problem.
Hi Stephen, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!
However, would it be possible for the field to recognize/check validity of the email, before clicking the “payment button”?
Perhaps some jQuery is needed?
Hey Richard, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!
Hi Austin, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!
Hi Rob, thanks for your comment! I just tested this again with Storefront theme and it works perfectly. Maybe your theme (or another plugin) is messing/conflicting with my snippet?
To troubleshoot, disable all plugins but WooCommerce and also switch temporarily to “Twentyseventeen” theme (load the snippet there in functions.php) – does it work? If yes, you have a problem with your current theme or one of the plugins.
Ciao Emiliano, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!
Hi, thank you for this code which is working great! The only thing is, that I can’t manage to make the field appear next to or at least after the current email field (which is last in order). It appears on the top of the page… Thank you a lot for your help.
Thank you again!
By changing the code as follows, shouldn’t I be able to adress the “Email Varification field” as well? I can’t manage to get that work… I can adress all other fields except the one I created using your code…
I’m having this same issue. This code used to make it show down the bottom next to the email field. But after the recent woo update it now shows up the top. Even using the rearrange as you’ve suggested won’t allow me to move this verification field. It always seems to show in the second place. So it goes First name, email verification then last name. The best I could get was putting email as the first field, but this isn’t ideal.
I added this snippet and it works but one major problem.
The email field is the last field in my checkout and the verification field is the first. In between are address phone etc.
I’m having the same issue. It was working perfectly but is now appearing at the top of the form.
I’ve tried to move using the reorder fields link, but that doesn’t appear to work.
Any other suggestions?
Thanks!
Thank you! Is there any way to trigger woocommerce-invalid class (red) when both fields are not the same, and trigger woocommerce-valid (green) when both fields are the same? Right know it triggers woocommerce-valid in both situations.
Hello Tatiana – thanks so much for your comment! Yes, this is possible – but unfortunately this is custom work and I cannot provide a complementary solution here via the blog comments. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding! ~R
Hey Tom – thanks so much for your comment! Try playing with the “form-row-last” class in the snippet – try changing that to “form-row-wide” or just “form-row”. Let me know
Hello!
Thanks for this solution, built into my customer’s webshop and works as described. I have a really dumb question, cause I’m not very good at writing codes:
I tried to add the phone filed with the same method duplicating this code and replaced the filed names to validate the billing_phone field. The new filed appears okay, but in the end, the function only gets the validation error for the e-mail field. I think I have to nest the two validate actions but I don’t know how to do this.
So I defined the filters individually, but the actions may be needed to be nested? How can I do that?
Thank You for Your answer!
*PS. I just duplicated the actions like this:
add_action('woocommerce_checkout_process', 'bbloomer_matching_email_addresses');
function bbloomer_matching_email_addresses() {
$email1 = $_POST['billing_email'];
$email2 = $_POST['billing_em_ver'];
if ( $email2 !== $email1 ) {
wc_add_notice( __( 'Emails does not match!', 'bbloomer' ), 'error' );
}
}
add_action('woocommerce_checkout_process', 'bbloomer_matching_phones');
function bbloomer_matching_phones() {
$phone1 = $_POST['billing_phone'];
$phone2 = $_POST['billing_ph_ver'];
if ( $phone2 !== $phone1 ) {
wc_add_notice( __( 'Phones does not match!', 'bbloomer' ), 'error' );
}
}
Hey Lukas, thanks so much for your comment! Yes, this is possible – but unfortunately this is custom work and I cannot provide a complementary solution here via the blog comments. Thanks a lot for your understanding! ~R
Thanks for the tutorial,
But i want to add a confirmation field in woocommerce checkout page and the form will be one on the billing field or any other user profile field but wont show on the checkout page only the confirmation field will show.
Example:
TRANSACTION PIN: user_password (but this field will not be seen on the checkout page but it exists in the user profile field and can be edited by user)
CONFIRM PASSWORD: user_password_confirm
(this field will be visible on the checkout page and the customer have to type the exact thing is in user _ pass before he can process checkout or submit order
Note: only the confirm pass field will be seen on the checkout page, while the Transaction pin is a field located in users profile field but will not been seen in the checkout page, and the input in confirm pass form in the checkout page must match exactly the value that the user already have in stored in the user_pass field. if not an error message will appear and order wont be processed.
Hey Chris, thanks so much for your comment! Yes, this is possible – but unfortunately this is custom work and I cannot provide a complementary solution here via the blog comments. Thanks a lot for your understanding! ~R
Thanks for this helpful tutorials. I test the code in our staging site and the email address verification appears below in the Postcode/ZIP not below in the Phone. Alignment is good. How to move the email address fields below the Phone like yours on the screenshot?
Thank you for the useful tutorials.
I tried the snippet in my local test site and the confirm email address field appears in the center of a new line. Since the email address field is next to the phone number field, those two fields don’t align.
How can you make those fields align like your screenshot?
Hey Michico, thanks for your comment! You will need to make the phone and billing email fields full width, you can use the exact same filter provided here. Sorry but I can’t help with custom coding via the blog comments. Thanks!
It almost worked, it added the second field, and did not detect the two addresses were different (but I didn’t click further, I thought it would detect right away when I moved on to the next field). It also hid the “subscribe to newsletter” field. I am using Pro Theme, so that probably has something to do with it.
Francie, thanks for your comment! Yes, the error shows when you submit the checkout, it’s only a PHP check and not a jQuery one. For the other issue, no idea, maybe your custom theme is indeed using the same hook and you need to merge the functions to make them work both ๐
Questions? Feedback? Customization? Leave your comment now! _____
If you are writing code, please wrap it like so: [php]code_here[/php]. Failure to complying with this, as well as going off topic or not using the English language will result in comment disapproval. You should expect a reply in about 2 weeks - this is a popular blog but I need to get paid work done first. Please consider joining the Business Bloomer Club to get quick WooCommerce support. Thank you!
This snippet works like a charm under WordPress 6.5.5 and woocommerce 9.1.0 as of today 12/07/2024 and additionnaly I’m using Breakdance Builder 2.0.0-rc.1
Thank you so much for this beautiful simple snippet !!! You save us with this !
Excellent
OK anyone able to help as I’m a total novice. I have the code on site and the confirm Box is there and working. However, I ask name then email address and a few other questions but the confirm email address option is at the very bottom. How do I get it beside the other enter email at top?
Try change the priority to 5 or 10 or something like that
This is an excellent snippet, but unfortunately I have found it raises a problem when used with the Saved Addresses for WooCommerce plugin, as I have just had a customer fail to check out using a saved address with the error “billing confirm mail address is a required field”.
It seems like the confirmation field is not present in previously saved addresses, and I will contact you in BloomerArmada to work out next steps.
Thanks.
Thank you! Yeah I guess the snippet will need to be tweaked a little in order to be compatible with the extension – feel free to email me the plugin ZIP and I can take a look
Can I make the user enter the mail again and don’t use copy-paste?
Hi Rubb, you can do so with some custom JS, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!
Hi there,
Great snippet! Thank you!
I’ve just noticed a small problem; when using an iPad this extra email field forces the email address to start with a capital first letter and this is obviously causing problems as it then doesn’t recognise the email addresses to be identical โ unless you go back and correct the first written letter that is; which some won’t think to do.
Any ideas for a fix to this?
Hope you can help and many thanks!
Thank you! You could compare strings with https://www.php.net/manual/en/function.strcasecmp.php instead, and this is case-insensitive
Works like a charm. However, is there a way to prevent users from copy pasting in this field ?
I found this html code to implement but not sure where to put in your code
Hello Sven, thanks so much for your comment! Yes, this is definitely possible via JS, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!
Hi there,
The functionality of the code seems to be limited when it comes to off-site payments. If the payment (off-site) fails, the customer is redirected back to the checkout page, where he has to fill out the email confirmation field again. Does anyone have an idea, how this could be solved?
Hello Johannes! Which payment gateway are you referring to? PayPal, for example, redirects back to the Cart as long as I see, so there’s no problem there
Hi Rodolfo,
Thanks for your feedback!
It’s a Swiss payment gateway (Postfinance) which redirects back to the checkout page, if the payment fails (or is cancelled bei the customer).
But actually I think it’s the same with PayPal: if the user is redirected back to the cart page after the payment has failed (or was cancelled by the user) and he proceeds to the checkout page again, he has to confirm his email address a second time, while the rest of the fields are prefilled. So it works in general, but it’s a little inconvenient for the customer if he has to confirm his email twice. But maybe this behaviour only occurs with our payment gateway?
Thanks for the clarification. Yes, this is due to Postfinance and the way it works, so I’m afraid this is custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!
It does not work with Paypal where paypal has to come back to the site to confirm order. That extra step always results in a false “emails don’t match error”
Thanks for your comment Shelley. Are you able to do another PayPal test for me please? If yes, please change the second part of the snippet to:
Then, send me via email what you see under /wp-admin/admin.php?page=wc-status&tab=logs in the “bbloomer” log file
Let me know
Work perfect – thank you!
Is there a way to highlight the email field with a red border on the error?
There should be, yes, try checking the CSS class of fields with validation error and try adding it to the snippet
Thank you for this – just what I was looking for.
I changed it slightly so it says confirm Email address, rather than mail – and was really chuffed with myself!
Awesome
Hi
FYI – I have found a glitch!
When you give a developer a user name and password in the dashboard, it asks to validate the password, but with no extra box to put it in!
This only happens on the dashboard – if a customer makes a new account, or logs in it is fine.
This is fine as I know about it, and just need to disable your code to provide the login
Thank you
Amy
That’s not possible Amy unless there is some sort of conflict with something else, as my code only runs when a WooCommerce checkout form is submitted
Hello,
This snippet is fine and works well.
Is there a solution to avoid autocompletion on the Confirm field ?
Thanks in advance for your help in getting this question solved.
Regards,
Michel
Not 100% sure Michel. I know you can add an input parameter but it depends on the browser
Works correct. But is it possible to validate when e-mailadres is with starting capital and confirmation not? Now you get an error but the e-mailadress works fine with capitals or not.
Regards,
Kees
Hello Kees, thanks so much for your comment! Yes, this is definitely possible, but Iโm afraid itโs custom work. If youโd like to get a quote, feel free to contact me here. Thanks a lot for your understanding!
Hello,
We have made the following changes in the code to make sure customer does not get error even if they add a space or enter the email address in capital in any of the field.
Wow thank you!
It works with Paypal, after adding comment from JD Farrell
It does work with Stripe credit card payments.
It doesn’t work for me with Stripe > Google Pay (and probably apple pay, still testing)
Google Pay doesn’t require you to fill any fields.
User clicks on pay now in Cart, user confirms payment in Android Pay, user is returned to checkout page with error that email adresses do not match, the payment never goes through.
There are ofc no email confirm fields to fill out on google pay, I guess their payment gateway posts back an email value, but the form fails.
Not sure how this can be avoided
I guess you’ve found a fix here: https://www.businessbloomer.com/woocommerce-add-confirm-email-address-field-checkout/#comment-368678
Is it possible to add the “woocommerce-invalid” class if the email fields does not match ?
Hi Simon, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!
Hello Rodolfo and thank you for this function , it work great on last version 2020
Is there a way to do this on woocommerce registration page as well? Any hint plz?
thank you
Hi Richard, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!
Still working and i just installed brand new WordPress with Woo 4.2 and php 7.3.16
Great code snippet. Thank you very much.
Great!
Thank you! This is still working perfectly in May 2020. Very simple and easy to understand — well done!
Cheers!
Hi, Just what I needed. Still working.
If the user is logged in they still see the confirm email address. Only a minor thing is this easy to fix?
Thanks.
Hey Martin! Yes you can use the is_user_logged_in() WordPress check to toggle it
Could you give an example of this, how to implement the is_user_logged_in()? This would make the code complete. Many thanks!
Sure. It’ll be something like:
Hey! Love the blog, I actually encountered an issue with the way validation was working for this snippet. It was rather confusing since PayPal would still open and let them process their information.
I followed woo source code to see how validation works. Changing the hook and adding the $error to the existing $error variable made it validate like the rest (various billing validation etc)
The above changes now validate before PayPal or any order processing is done. The issue was, the money would get validated from paypal and get placed on-hold from bank which would eventually get returned since never processed by PayPal.
FANTASTIC! Thank you
Thank you,
it was working well until I encountered Stripe Google Pay / Apple Pay payments
I found the following workaround:
after that android pay was still complaining that billing_em_ver field is required, and I was not able to unset it in the error handling,
so I just set [‘billing_em_ver’] required from Step2 to false
I guess the “email fields are different” is a sufficient error anyway
Cool
Thanks for posting this code!
One problem I ran into. When a customer checks out using PayPal (customer clicks the paypal button before they input their email) they automatically get redirected to the final checkout page. When this happens, Paypal fills out their name and email account for them so when they click the final purchase button, it says their “emails do not match” but there is no option to confirm their email since Paypal redirected them.
Not sure if that makes sense, but it basically removes a customers ability to checkout with Paypal if they don’t pre-fill their information which is a big problem.
Hi Stephen, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!
Great snippet!! Still working:
WooCommerce: 3.9.0
WordPress: 5.3.2
Thank you!
Still works to date ๐
However, would it be possible for the field to recognize/check validity of the email, before clicking the “payment button”?
Perhaps some jQuery is needed?
Hey Richard, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!
Hi Rodolfo
If your were able to adapt this: https://kimjoyfox.com/using-jquery-to-confirm-email-before-submitting-a-form/ it will be awesome!
Much easier than all that PHP code, don’t you think?
Thanks
If only I had the time ๐
hello, how can I add email verification after registration?
Hi Austin, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!
Maybe a tiny improvement to not directly access $_POST.
Thank you!
Thanks, still working.
Great!
Hi, I got the field but my problem is that the code gives only an error when the verification field is empty. What can I do for this problem?
Just tested on Woo 3.8, still works perfectly. Sorry
Still working! Thank you!!!!
Awesome
Not working for me now. Using code exactly as provided above.
Hi Rob, thanks for your comment! I just tested this again with Storefront theme and it works perfectly. Maybe your theme (or another plugin) is messing/conflicting with my snippet?
To troubleshoot, disable all plugins but WooCommerce and also switch temporarily to “Twentyseventeen” theme (load the snippet there in functions.php) – does it work? If yes, you have a problem with your current theme or one of the plugins.
Hope this helps!
R
Thanks for updation
You’re welcome ๐
Hello,
There is any way alsoto add confirm email field in registration?
Ciao Emiliano, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!
It is, indeed, still working on WP 4.9 and the latest WC. thanks
Brilliant!
Itยดs work
Nice ๐
Rodolfo,
Thank you for updating this script ๐
You’re welcome ๐
This would be great on the user registration, even better if you provide a tutorial on it.
Many users make the mistake on registration too.
Anyhoo, very nice to have extra option for the checkout process
Thanks Chris, I’ll see what I can do ๐
I second this!!!!
Hi, thank you for this code which is working great! The only thing is, that I can’t manage to make the field appear next to or at least after the current email field (which is last in order). It appears on the top of the page… Thank you a lot for your help.
Thank you Dana! See https://businessbloomer.com/woocommerce-add-confirm-email-address-field-checkout/#comment-51640
Thank you again!
By changing the code as follows, shouldn’t I be able to adress the “Email Varification field” as well? I can’t manage to get that work… I can adress all other fields except the one I created using your code…
Thank you again!
Hey Dana, I think Woo has a bug with reordering fields – see first comment on that other tutorial
I’m having this same issue. This code used to make it show down the bottom next to the email field. But after the recent woo update it now shows up the top. Even using the rearrange as you’ve suggested won’t allow me to move this verification field. It always seems to show in the second place. So it goes First name, email verification then last name. The best I could get was putting email as the first field, but this isn’t ideal.
Hi
I added this snippet and it works but one major problem.
The email field is the last field in my checkout and the verification field is the first. In between are address phone etc.
How can I change the order?
Hey Max, thanks for your comment! Read this: https://businessbloomer.com/woocommerce-move-reorder-fields-checkout-page/
I’m having the same issue. It was working perfectly but is now appearing at the top of the form.
I’ve tried to move using the reorder fields link, but that doesn’t appear to work.
Any other suggestions?
Thanks!
Works for me on Storefront theme and latest Woo. Try disable all plugins but Woo + switch theme temporarily – does it work?
Hello,
Thank you! Is there any way to trigger woocommerce-invalid class (red) when both fields are not the same, and trigger woocommerce-valid (green) when both fields are the same? Right know it triggers woocommerce-valid in both situations.
Hello Tatiana – thanks so much for your comment! Yes, this is possible – but unfortunately this is custom work and I cannot provide a complementary solution here via the blog comments. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding! ~R
hey there. the snippet works great however its aligned in the middle. how can i align it left as per the rest of the fields?
thank you in advance.
Tom
Hey Tom – thanks so much for your comment! Try playing with the “form-row-last” class in the snippet – try changing that to “form-row-wide” or just “form-row”. Let me know
Hello!
Thanks for this solution, built into my customer’s webshop and works as described. I have a really dumb question, cause I’m not very good at writing codes:
I tried to add the phone filed with the same method duplicating this code and replaced the filed names to validate the billing_phone field. The new filed appears okay, but in the end, the function only gets the validation error for the e-mail field. I think I have to nest the two validate actions but I don’t know how to do this.
So I defined the filters individually, but the actions may be needed to be nested? How can I do that?
Thank You for Your answer!
*PS. I just duplicated the actions like this:
Hey Arpad, code looks good to me. Did you set the phone number as “required”?
hello, how can I add email verification after registration? something like user receives an email with activation after registration
Hey Lukas, thanks so much for your comment! Yes, this is possible – but unfortunately this is custom work and I cannot provide a complementary solution here via the blog comments. Thanks a lot for your understanding! ~R
okay, so how can we go about the custom work and how can you be of help.
thanks
Hey Chris, thanks so much! If you’d like to get a quote, feel free to contact me here
Thanks for the tutorial,
But i want to add a confirmation field in woocommerce checkout page and the form will be one on the billing field or any other user profile field but wont show on the checkout page only the confirmation field will show.
Example:
TRANSACTION PIN: user_password (but this field will not be seen on the checkout page but it exists in the user profile field and can be edited by user)
CONFIRM PASSWORD: user_password_confirm
(this field will be visible on the checkout page and the customer have to type the exact thing is in user _ pass before he can process checkout or submit order
Note: only the confirm pass field will be seen on the checkout page, while the Transaction pin is a field located in users profile field but will not been seen in the checkout page, and the input in confirm pass form in the checkout page must match exactly the value that the user already have in stored in the user_pass field. if not an error message will appear and order wont be processed.
Hey Chris, thanks so much for your comment! Yes, this is possible – but unfortunately this is custom work and I cannot provide a complementary solution here via the blog comments. Thanks a lot for your understanding! ~R
Thanks for this helpful tutorials. I test the code in our staging site and the email address verification appears below in the Postcode/ZIP not below in the Phone. Alignment is good. How to move the email address fields below the Phone like yours on the screenshot?
Thanks.
I noticed you found the other similar comment ๐
Hello,
Thank you for the useful tutorials.
I tried the snippet in my local test site and the confirm email address field appears in the center of a new line. Since the email address field is next to the phone number field, those two fields don’t align.
How can you make those fields align like your screenshot?
Thank you.
Hey Michico, thanks for your comment! You will need to make the phone and billing email fields full width, you can use the exact same filter provided here. Sorry but I can’t help with custom coding via the blog comments. Thanks!
I have the same issue. Is this issue resolved? How? Can you post a comment, please? Thank you,
Respectfully,
Billy
It almost worked, it added the second field, and did not detect the two addresses were different (but I didn’t click further, I thought it would detect right away when I moved on to the next field). It also hid the “subscribe to newsletter” field. I am using Pro Theme, so that probably has something to do with it.
Francie, thanks for your comment! Yes, the error shows when you submit the checkout, it’s only a PHP check and not a jQuery one. For the other issue, no idea, maybe your custom theme is indeed using the same hook and you need to merge the functions to make them work both ๐