WooCommerce Profit Reports
Like You've Never Seen Before

Let's Simplify Your Checkout

There are quite a few layers of validation to the Woocommerce checkout.

The scenario I found myself in, is that I let users create an account on checkout to promote loyalty.

The problem is, if they come back to make a second purchase with that same email address they will not be able to proceed.

They will be faced by the following irritating error.

Fortunately, it’s pretty easy to fix.

The issue for me was that if a user leaves the checkbox ticked for “create account” which I had left by default and they try to check out using an email that exists, Woocommerce will try to create an account and then of course throw this error because the email exists.

Add This To Functions.php

 *	Let the user checkout as guest even if they have an account
 *	@todo tie the order to an email
add_filter( 'woocommerce_checkout_posted_data', 'ftm_filter_checkout_posted_data', 10, 1 );
function ftm_filter_checkout_posted_data( $data ) {

	$email = $data['billing_email'];

	if ( email_exists( $email ) ) $data['createaccount'] = 0;

	return $data;


What Does This Do?

Before a checkout is submitted and begins processing, all of the data is passed through this filter.

This let’s you modify any of the checkout fields before they go through the usual WC flow.

Here, we are grabbing the submitted email address and checking if the user already has an account.

If they do, we are making sure they are not trying to create an account which is where WC will crack the dummy.

What Else?

I’ve also created a small bit of script that checks their email address as they type it in.

If the typed email address matches an account, a small field will appear below the email address input asking them if they want to log in.

Haven’t included it here, that’s something for another day.

Let me know in the comments how you go or if you have any other ideas for cool WC developments.

Cheers, Chris

Related Post

Notify of
Newest Most Voted
Inline Feedbacks
View all comments
2 years ago

Hi, could you please share the code snippet for “If the typed email address matches an account, a small field will appear below the email address input asking them if they want to log in.”? 🙂 Thanks.

2 years ago

This is just what i am after. We have an issue with people not logging in and then trying to complete the cart and of course they get the small error message about email already exists, but they don’t see it.
Where are you adding this code? in Functions.php?Thanks

2 months ago

A site that was working perfectly now shows “An account is already registered with your email address. Please log in.” for new emails that have not been used before. The snippet for functions.php has no effect. Any ideas what could be the issue?

Recent Posts