How to Automatically Register Guest Checkouts in WooCommerce

How to Automatically Register Guest Checkouts in WooCommerce
On this page
  1. Why Convert Guest Orders Into Accounts
  2. Step 1: Create the Account After Payment
  3. Step 2: Confirm Guest Checkout Stays Enabled
  4. Troubleshooting
  5. Frequently Asked Questions
  6. Conclusion

You can automatically register guest checkouts in WooCommerce by hooking into woocommerce_thankyou to create a customer account from the order’s billing email right after payment, then linking any past guest orders to that new account with wc_update_new_customer_past_orders.

Why Convert Guest Orders Into Accounts

  • Registered customers are easier to remarket to and show a full order history in My Account
  • You avoid asking customers to register at checkout, which can hurt conversion rates
  • Past guest orders get retroactively linked once the account exists
  • It works well for stores that keep “guest checkout” enabled purely for a faster checkout experience

Important: automatically creating accounts without explicit consent can run into privacy/consumer-protection rules depending on your country — check local requirements before relying on this in production, and consider disclosing it in your checkout terms.

Step 1: Create the Account After Payment

This snippet hooks into the thank-you page action, checks whether the billing email already has an account, and if not, creates one and logs the customer in automatically.

PHP
/** Turn a guest order into a registered account right after checkout */
add_action( 'woocommerce_thankyou', 'convert_guest_order_to_account', 20 );

function convert_guest_order_to_account( $order_id ) {
    if ( ! $order_id ) {
        return;
    }
    $order = wc_get_order( $order_id );
    $email = $order->get_billing_email();

    if ( email_exists( $email ) || username_exists( $email ) ) {
        $user = get_user_by( 'email', $email );
        wc_update_new_customer_past_orders( $user->ID );
        return;
    }

    $new_user_id = wc_create_new_customer( $email, '', '', array(
        'first_name' => $order->get_billing_first_name(),
        'last_name'  => $order->get_billing_last_name(),
    ) );

    if ( is_wp_error( $new_user_id ) ) {
        return;
    }

    wc_update_new_customer_past_orders( $new_user_id );
    wc_set_customer_auth_cookie( $new_user_id );
}

Step 2: Confirm Guest Checkout Stays Enabled

This only works if WooCommerce > Settings > Accounts & Privacy > “Allow customers to place orders without an account” is switched on — the snippet has nothing to convert if guest checkout is disabled. You can then optionally turn off the “create an account during checkout” checkbox, since every order becomes an account regardless.

Troubleshooting

Customer Isn’t Logged In After Checkout

Confirm nothing else on the thank-you page is redirecting before wc_set_customer_auth_cookie() can run — some upsell or tracking plugins hook the same action with a redirect at a similar priority, which can short-circuit this snippet.

Duplicate Account Errors on a Second Order

The email_exists() check should prevent this, but if a customer signs up manually between two guest orders using a slightly different email casing, WordPress may still treat it as a new account — this is a rare edge case worth monitoring in your user list.

Frequently Asked Questions

Is it legal to auto-register customers without consent?

It depends on your jurisdiction’s consumer protection and privacy laws — many regions require clear disclosure or opt-in before creating an account on someone’s behalf, so review this with a local advisor before deploying it.

What password does the new account get?

WooCommerce generates a random password and emails the customer a “welcome” or password-reset style notification, depending on your account email settings.

Can I limit this to specific order totals or products?

Yes — wrap the account-creation logic in a condition checking $order->get_total() or the order’s line items if you only want to auto-register above a certain order value.

Conclusion

Auto-registering guest checkouts removes the friction of asking shoppers to create an account up front while still giving you a proper customer record for every sale. Just make sure your checkout policy discloses the behavior so it doesn’t surprise anyone. Getting this right is really what automatically register guest checkouts in woocommerce comes down to.

See also How to Redirect to Checkout Automatically on Add to Cart in WooCommerce. Then read How to Automatically Update the WooCommerce Cart on Quantity Change.

Prefer no code? All-in-One Utilities Woo Add-on adds over 50 WooCommerce features, so you can switch them on without code.

Leave a Reply

Schedule a call