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        Watch tutorial @ https://businessbloomer.com/?p=19055
 * @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 code?

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 delicate files - if you need more guidance, please take a look at my free WooCommerce Customization video tutorial.

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?

Check out these free videos, tutorials and tips!

  • how-to-edit-woocommerce-with-php-snippets
  • woocommerce-hooks-add_action-list-visual
  • woocommerce-customize-single-product-page-PHP
  • woocommerce-customize-shop-page-PHP
  • woocommerce-advanced-customization
  • how-to-edit-woocommerce-cart
  • woocommerce-customize-checkout-page-PHP
  • woocommerce-email-customization
  • woocommerce-conditional-logic

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.

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

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

  2. 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 *

This site uses Akismet to reduce spam. Learn how your comment data is processed.