I got a purchase receipt email recently that had a lot of great details, such as the shipping status of each item ordered, along with some related items that I might be interested in. However, there was one section that I found kind of interesting: the email had a registration prompt telling me all of the benefits of creating an account with the site.

I thought this was pretty neat, and adding a prompt like this to any guest purchase on your store is fairly straight-forward, so we’re going to look at adding a registration prompt to WooCommerce customer emails today.

We’ll add this prompt only to (1) emails sent to the customer, and (2) emails for orders that were placed by a guest.

Add the Registration Section to WooCommerce Customer Emails

Let’s start with what this is going to look like. Our goal here is to add a registration prompt to any customer email sent for a guest purchase. This registration prompt will inform the customer of the benefits of creating an account, and will also give customers a link right to the registration form on the “My Account” page.

WooCommerce Customer Email: Registration prompt added

Email Registration prompt

Before you do this, you may want to be sure you allow registration from the account page. Otherwise, this prompt will be useless.

So first thing: let’s decide where to add this prompt. I’m going to use the woocommerce_email_order_meta action, which will add my prompt right after any pertinent order details, and before any customer details or other information. However, you can move this as desired by using a different email template hook.

Next, we need to get the URL of the “My Account” page so we can link to it. We can retrieve it as we’ve outlined in our post on getting the URLs of WooCommerce pages:

$my_account_url = get_permalink( get_option( 'woocommerce_myaccount_page_id' ) );

As the order emails pass the $order object into actions for our use, the quickest way to check for a guest order is something like this:

if ( ! $order->get_user() )

The get_user() class method will return false for guest purchases, so it’s an easy check for a guest order. We’ll also check if ( ! $sent_to_admin ) ) for this bit of code so we only add our prompt to customer emails.

Now we get to the meat of this: creating our customer registration prompt. I’m going to create the text you saw in my screenshot, and link to the account URL I got a bit earlier. I’ll buffer this output, so I’ll echo ob_get_clean() instead of echoing my HTML directly (just like you do with shortcodes).

That’s all it takes! This section will now be added to your guest WooCommerce customer emails. There are a couple things we can, however, use to take this a bit further.

First, if you upgrade to WooCommerce 2.5, you can make a slight change to this snippet if desired. The WooCommerce 2.5 customer email templates add the $email variable to the order email actions. This allows you to use email data, such as the email ID, in your custom snippet. You could then choose to add the registration prompt only to certain emails.

For example:

// bail unless we're sending the 'processing order' email
if ( 'customer_processing_order' !== $email->id ) {

Second, we added something to the end of our “My Account” page link that you may have noticed:

'?email=' . urlencode( $order->billing_email )

Instead of putting out a link like, we’ll link to:

This is going to let us put on an additional bit of polish, as is The SkyVerge Way™ — we can use the customer’s email to pre-fill part of the registration form and make registration even faster.

Bonus: Pre-fill Registration Forms with Customer Emails

Now that our customer emails prompt guest users to register, we can help them with registration by pre-filling the customer email in the registration form. The email URL parameter we added will pass the email to our form, and can fetch it and change the form.

WooCommerce is going to give us a ton of help here, as it checks for the $_POST['email'] value to prefill the registration form. This isn’t typically set, so nothing is pre-filled.

However, we can use an action before this field, such as woocommerce_register_form_start, to set this value to $_GET['email'] from our URL, and then WooCommerce will use this to pre-populate the form.

This is going to use the email I’ve passed in via URL (which is the billing email for the order), and set it in the registration form:

WooCommerce registration prompt -- pre-filled registration email

Pre-filled registration email

This makes registration from my customer emails super fast and simplifies this step for customers so all they have to do is enter a password (and a username if you don’t already generate it from the email).

Double Bonus Round

While you’re at it, and since you already have the snippet to pre-fill email addresses, you could also add this as a notice to the order’s “Thank you” page as well.

WooCommerce thank you page registration prompt

Encourage your guest purchasers to register by giving them reasons to along with an easy registration link 🙂

Published by Beka Rice

Beka leads product direction for SkyVerge and technical documentation. She spends a lot of time on research and interviews, but likes to write so she has an excuse to spend more time jamming out to anything from The Clash to Lady Gaga.


  1. This is perfect. Thank you for sharing this. It is just what I need for a project I’m working on. 🙂

  2. Very interesting article! I’m curious, though: how would you reconcile a previous order when a guest user registers? In other words: say I buy from your store and use my email ( at checkout. I then get this lovely email with a registration prompt, so I go and register.

    The problem is, I don’t have any orders in My Account. This leaves me confused.

    Would you have a super simple double secret bonus round up your sleeve to help with this? Or am I completely missing something?

  3. where do I add that code?

Hmm, looks like this article is quite old! Its content may be outdated, so comments are now closed.