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, 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“.

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 Customer to “Pay for Order” if Logged Out (WooCommerce Checkout)

 * @snippet       Pay for Order if Logged Out - WooCommerce Checkout
 * @how-to        Get CustomizeWoo.com FREE
 * @author        Rodolfo Melogli
 * @compatible    WooCommerce 3.6.2
 * @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;

Where to add this snippet?

You can place PHP snippets at the bottom of your child theme functions.php file (before "?>" if you have it). CSS, on the other hand, goes in your child theme 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 free video tutorial "Where to Place WooCommerce Customization?"

Does this snippet (still) work?

Please let me know in the comments if everything worked 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 on PHP 7+.

If you think this code saved you time & money, please join other Business Bloomer supporters and avail of 365 days of WooCommerce benefits. Thank you in advance :)

Need Help with WooCommerce Customization?

Check out these free video tutorials. You can start learning how to customize WooCommerce without unnecessary plugins. Watch me code and learn by example!

  • how-to-edit-woocommerce-with-php-snippets
  • woocommerce-hooks-add_action-list-visual
  • woocommerce-customize-single-product-page-PHP

Rodolfo Melogli

Author, WooCommerce expert and WordCamp speaker, Rodolfo has worked as a 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.

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

  1. 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!

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

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

  3. 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!


  4. thank you so much for your help

    1. Welcome!

  5. 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!

  6. 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 ๐Ÿ™‚

  7. 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: [php]code_here[/php]. Failure to complying with this (as well as going off topic) will result in comment deletion. You should expect a reply in about a week - this is a popular blog but I need to get paid work done first. Please consider joining #BloomerArmada to ask me 1-to-1 WooCommerce questions. Thank you :)

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