WooCommerce: Allow to “Pay for Order” Without Login

Some plugins such as “deposit” and “subscription” payments send customers to the “Pay for Order” page in order to complete a pending WooCommerce order.

In certain cases, also, the customer is forced to log in and this really affect sales conversion rate – instead of the checkout form customers see this notice: “Please log in to your account below to continue to the payment form“.

On top of that, there is another notification error for guest orders: “To view this page, you must either login or verify the email address associated with the order” – we’ll fix that as well.

Here’s a quick snippet to make sure customers do not have to log in when on the “Pay for Order” page, so that they can immediately go ahead with the payment.

The WooCommerce function in question is wc_customer_has_capability, and thankfully we can override this with the user_has_cap filter. Enjoy!

Screenshot of the “Please log in to your account below to continue to the payment form” notice that appears on the “Pay for Order” page

PHP Snippet: Allow Customers to “Pay for Order” if Logged Out @ WooCommerce Order Pay Checkout

 * @snippet       Pay for Order if Logged Out - WooCommerce Order Pay
 * @how-to        Get CustomizeWoo.com FREE
 * @author        Rodolfo Melogli
 * @compatible    WooCommerce 8
 * @donate $9     https://businessbloomer.com/bloomer-armada/

add_filter( 'user_has_cap', 'bbloomer_order_pay_without_login', 9999, 3 );

function bbloomer_order_pay_without_login( $allcaps, $caps, $args ) {
	if ( isset( $caps[0], $_GET['key'] ) ) {
		if ( $caps[0] == 'pay_for_order' ) {
			$order_id = isset( $args[2] ) ? $args[2] : null;
			$order = wc_get_order( $order_id );
			if ( $order ) {
				$allcaps['pay_for_order'] = true;
	return $allcaps;

add_filter( 'woocommerce_order_email_verification_required', '__return_false', 9999 );

Where to add custom code?

You should place PHP snippets at the bottom of your child theme functions.php file and CSS at the bottom of its style.css file. Make sure you know what you are doing when editing such files - if you need more guidance, please take a look at my guide "Should I Add Custom Code Via WP Editor, FTP or Code Snippets?" and my video tutorial "Where to Place WooCommerce Customization?"

Does this snippet (still) work?

Please let me know in the comments if everything went as expected. I would be happy to revise the snippet if you report otherwise (please provide screenshots). I have tested this code with Storefront theme, the WooCommerce version listed above and a WordPress-friendly hosting.

If you think this code saved you time & money, feel free to join 17,000+ WooCommerce Weekly subscribers for blog post updates and 250+ Business Bloomer supporters for 365 days of WooCommerce benefits. Thank you in advance!

Need Help with WooCommerce?

Check out these free video tutorials. You can learn how to customize WooCommerce without unnecessary plugins, how to properly configure the WooCommerce plugin settings and even how to master WooCommerce troubleshooting in case of a bug!

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.

66 thoughts on “WooCommerce: Allow to “Pay for Order” Without Login

  1. Hi Rodolfo,

    Your code works for initially loading the payment page without logging in. However, if the customer attempts the payment and it fails, they are redirected to a page telling them to log in or provide their email address. This seems to be new since WC 7.9.0.

    1. I see. What’s the URL of this page?

      1. I ahev the sime error, afeter payed the order, dont go on the thankyoupage

        1. Ciao Giuseppe, this looks like a different error than the one mentioned above (on payment failed). Yours is when payment is successful, correct?

          1. Yes, the order is payment successful. but dont go on thankyou page and i see the login form?
            How to correct this?

            1. I’ve just tested it again. It works perfectly when a logged out user pays for a guest order.

              Other scenarios where the logged in user is different than the order customer (non guest order), you will get the login page instead.

  2. Hi Rodolfo,

    I have applied the code and nothing happened, the issue came up in one of the latest WC update.

    1. Hey Wagner, what do you mean by “nothing happened”? Please note I’ve edited the snippet since Woo 7.8, and it’s working for me on this same website

      1. I am using the WC 7.9.0 and here is an example of a page where was used to show a simple thank you page for non logged users – we don’t ask for user registration, only guests.

        Your post was one of the few option for the issue that I have but even though I am still receiving the message to login with email. (once I include my email it launches the thankyou page, but the purchase tracking is on thankyou page and I can’t expect the user will include their email)

        Here is an example of how the page should load in stag: https://dev.uccellodesigns.co.uk/checkout/order-received/34005/?key=wc_order_d26GE0EkNhYFB

        I also update all settings available on WC admin dashboard.
        Have you any idea of what it can be?

        1. The line

          add_filter( 'woocommerce_order_email_verification_required', '__return_false' );

          removes that “login or verify” wall. Try again please

          1. I have also encountered the same problem as Wagner. It works to allow the guest to pay but upon successful payment it navigated to a page that asks for a login.

            1. Try using a priority of 999 – see updated snippet. Also please make sure the user who is paying for the order is not logged in. Let me know

  3. Much appreciated, thank you. On the pay_for_order page no more login for users and no email confirmation for guests , super !

    With GeneratePress theme and Snippets plugin.

  4. Just added this today and seems to work fine. WP 5.8 WC 6.0

  5. Is there anyway i can placed order without filling billing form..

    when i just click on Add to card Button redirect to asking payment page. just user complete payment and than go account page and fill details if he want to provide. otherwise no need to ask details.

    1. Hi Alkesh, 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!

  6. Forgot to say, that the code I have provided, also allow to pay for open order without logging in. I mean that you can manually create an order in WooCommerce admin dashboard, and then give a link to customer for pay. So, with the code located above, the customer dont need to provide login and password. The customer can pay without any “you need to log in to pay for this order…”

    So, the code do the two things:

    1. Allow pay for order without logging in during the usual order using “add to cart” (recognizing customer using e-mail that he provide at form during checkout and then add his new order to existing profile. It can be convenient for LMS LearnPress for example – non-logged old user with old e-mail, buys a new course and new course automatically adding to his account)

    2. Allow pay for open order which been created through admin dashboard without needed of entrance in account from the side of an user.

  7. Our team have developed the solution to allow orders from existing customers without logging in.

    The solution have been tested on WooCommerce v5.3.0 and v5.4.0 (June 2021).

    The system uses e-mail address to recognize whether is it new customer or old. If it new user, then new account will be create during a checkout as usual. If this is a new order from OLD user with old e-mail address in database, then new order will be added to existing WordPress profile. There won’t be any messages like “user already registered, please, login)

    How does the code works?

    When a non-logged in user with existing profile clicks on “proceed to checkout” button, the code use cookie to authenticate user without password for a very short time to trick the woocommerce system. Then immediately logs user out and moves on to the normal checkout process.

    Here is the code. You need to put it in your theme “function.php” file (to end of the file or to top of the file):

    // Allow WooCommerce existing customers to checkout without being logged in (allow orders from existing customers in WooCommerce without logging in)
    function your_custom_function_name( $allcaps, $caps, $args ) {
    	if ( isset( $caps[0] ) ) {
    		switch ( $caps[0] ) {
    		case 'pay_for_order' :
    		$order_id = isset( $args[2] ) ? $args[2] : null;
    		$order = wc_get_order( $order_id );
    		$user = $order->get_user();
    		$user_id = $user->ID;
    		if ( ! $order_id ) {
    		  $allcaps['pay_for_order'] = true;
    		$order = wc_get_order( $order_id );
    		if ( $order && ( $user_id == $order->get_user_id() || ! $order->get_user_id() ) ) {
    		  $allcaps['pay_for_order'] = true;
    	return $allcaps;
    add_filter( 'user_has_cap', 'your_custom_function_name', 10, 3 );
    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 ( is_user_logged_in() ) {
    	} else {
    		if (email_exists( $email)){
    			$user = get_user_by( 'email', $email );
    			if ($user){
    				$user_id = $user->ID;
    				$_SESSION['p33'] = "133";			
    				$_SESSION['u'] = $user_id;			
    			} else {
    				$user_id = false;
        return $data;
    add_action( 'woocommerce_new_order', 'clearuser' );
    function clearuser($data) {
    	if ($_SESSION['p33']==133){
    		$yourSession= WP_Session_Tokens::get_instance($_SESSION['u']);
    //End Allow Woocommerce Order Pay Without LogIn
    1. This Worked like A Charm,
      But On Checkout Page the Message is Still Displayed on Top…
      If you are a returning Customer Click to login.. That defeats the Purpose Slightly

      1. Mikhail, that’s awesome code, it worked great. The order was added to the existing account without having to login. Thank you!

  8. Thanks for sharing this script. It worked like a charm. I don’t know why there isn’t more solutions around sending WooCommerce invoices without the user needing to be logged in.

  9. Can’t seem to get this working with WP 5.6.2, WOO 4.9.2 and Subscriptions 3.0.11. When an user hit the ‘pay now’ button in the subscription renewal email, they are still redirected to the ‘my-account’ page. Anyone who got this working with subscriptions?

  10. Hey,,
    Code worked perfect with by passing the log in page which is awesome..

    But now After paying through PayPal the payment doesn’t go through and it just returns to the website with no items in cart..

    Payments were going though previously..

    Code error in log is

    [L_ERRORCODE0] => 10486

    Which is weird because that state it’s a card issue when it’s 100% isn’t the card

    1. Strange! Is that WooCommerce 5.0?

      1. Very strange!

        There is no error logs now, just returns to cart saying nothing in cart.

        Yes woo commerce 5.0

        As soon i remove your code, payment goes through when logged into an account.

        All setting on woo commerce are set to only check out as guest.

        1. And if you temporarily revert to Woo 4.9?

          1. Same issue!

            Any recommendations?

            It doesn’t seem to be an issue with the website or else it would get as far as the PayPal payment?


            1. Bump, has anyone been able to solve this issue?

  11. We are releasing a plugin for this, this week – does anyone still require this? If so let me know!

      1. Hi! Is this plugin yet released & does it also work for subscriptions?


        1. Hello! Have you realized the plugin? Could you tell the name of the plugin?

  12. I am unfortnunately reporting that the code does not work for me either: I am running WordPress 5.6, WooCommerce 4.9, no Gutenberg, just a standard checkout. I installed the code to my functions.php file. But when trying to place a test order using a customer identity that already has a WordPress registration (but hasn´t placed a WooCommerce order yet), the WooCommerce checkout does not allow the order (for a product, not a subscription) to be placed – it says that a registration already exists and ask the user to log in before finishing the order.

    This surely must be a huge issue for all/anyone selling anything using a WooCommerce store: Forcing existing customers to log into their account is a major sales deterrent. A since lot of customers don´t remember their account details, they often have to go though a password reset first. But if we force them to do (log in to their account, but since they don´t rememeber their passwords they have to do a password reset first) this whilst in the middle of ordering, they will just abandon the order and go somewhere else.

    Am I wrong in thinking that there must be a simple solution to this (and this code not necessary at all)? Or are all those hundreds of thousands of people using a WooCommerce store just throwing their potential orders away by forcing their clients to log in before placing an order?

    1. Weird, I use this snippet on Business Bloomer checkout. Maybe your theme (or another plugin) is messing/conflicting with my snippet.

      To troubleshoot, disable all plugins but WooCommerce and also switch temporarily to “Twentytwenty” theme (load the snippet there in functions.php) as explained here: https://www.businessbloomer.com/lesson/trwm4l01/

      Once you do that, does it work? If yes, you have a problem with your current theme or one of the plugins.

      Hope this helps!

  13. Hi, tested on WordPress 5.5.1 with WooCommerce 4.5.1 and it is definitely not working at all. Login is still required to pay for order. The only thing that helped was removing two specific blocks from wp-content/plugins/woocommerce/includes/shortcodes/class-wc-shortcode-checkout.php
    Update of this snippet for newest WP & WOO would be appreciated …

    1. Maybe it doesn’t work with WooCommerce checkout Gutenberg block? Works on the default checkout, and I have no intention of using Gutenberg on the checkout – sorry

      1. Having the same (i think) issue, clean WordPress 5.5.1 with WooCommerce 4.5.2 and StoreFront (tried with other ones as well) theme.

        Adding code to the functions file and it still giving “Oops! That page can’t be found.” whiles trying to access “/order-pay/41?pay_for_order=true&key=wc_order_XDhEK1P3ekpJE” type of URL as logged out user.

        1. Please ignore my previous comment as it does work properly and the issue was with the client not adding all the needed billing fields.

          1. Nice!

            1. Hello, Mirek. Could you tell me what specific block have you removed?

  14. This one will work with latest version:

    public function my_woocommerce_before_checkout_form($checkout) {
         remove_filter( 'woocommerce_checkout_registration_required', '__return_true', 0 );
    add_action( 'woocommerce_before_checkout_form', array($this,'my_woocommerce_before_checkout_form'), 10, 1 );
    1. Mine still works, actually

      1. Where to put it, Gil?

  15. This snippet is great! Thanks for putting this together!

    It does not work for renewal orders for subscriptions. I think that is because by default the pay for order page goes to the My Account page. Any thoughts on bypassing that so that a subscriber could pay without logging in??

    Thanks in advance!

    1. Hi Meg, 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!

  16. Hi,

    This snippet doesn’t work on last WooCommerce version (

    1. Screenshot?

      1. I had the same experience tried adding the snippet to my child theme and it is still making me log in to pay for a order (woocommerce subscription order)

        1. I understand this was not created for woocommerce subscriptions is there anyway to get that functionality with subscriptions plugin

          1. Hey Levi, 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!

  17. Hi,

    Interesting post. I have a similar problem.

    If I manually created an order without any info, how can I grant anyone with the link access without logging in?
    Slug example: order-received/view-order/XXXX.
    WooCommerce doesn’t authorise access because the order is not associated with an email address or account. My goal is to manually permit downloads through the order page.


    1. Hi Connor, 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!

  18. Hi,
    Does this work with the woo subscription plugin?

    1. Don’t know James, did you try by any chance?

  19. It doesnt work anymore after recent woocommerce update as of OCT-30-2019

    1. Hi Sam, 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!


  20. thank you so much for your help

    1. Welcome!

  21. Hi,

    Thank you for this. I was looking for this for the last 3 days.

    My customers usually have difficulties about login to pay their “pending payment” and for “renewal payments.”
    I am using Woocommerce Subcipriton to sending renewal notifications.
    What I wanted is letting customer click the link on their email and go to payment page directly without any login.

    I tested your code, it looks like working without Subscription plugin.
    But when I activated the subscription plugin it is redirecting to login page again with this URL

    It needs modification for Subscription but I have no idea how to do it.

    There is another ongoing discussion about this case on this URL: https://wordpress.org/support/topic/order-pay-without-login/

    I tested the code on that link too but the same result. Definitely, need some modification for Subscription.

    I just want to share my experience.

    Thank you for your work.

    1. Thank you!

  22. Hi Rodolfo!!! Again, one more great feature in this post!! thank you!!

    One question so, even if the user doesn’t have a registered account, once we send him the order url he will be able to pay no?

    1. I think so – do some tests and let me know 🙂

  23. Hi Rodolfo,
    Can you think of any risk with this snippet from a security perspective ?
    E.g. could a customer pay the wrong order ? could a hacker access order details ? etc

    1. Hello Jean 🙂 If WooCommerce is forcing login, for sure there must be a reason. However when I go to the “Pay for Order” page I don’t think there is sensitive data (please test), so it’s anonymous as long as I know.

Questions? Feedback? Support? Leave your Comment Now!

If you are writing code, please wrap it between shortcodes: [php]code_here[/php]. Failure to complying with this (as well as going off topic, not writing in English, etc.) will result in comment deletion. 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 BloomerArmada to get blog comment reply priority, ask me 1-to-1 WooCommerce questions and enjoy many more perks. Thank you :)

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