In some WooCommerce setups, customers who select an offline payment (like Cash on Deliver or Check/Cheque) and then change their mind and go into the order to pay for it using an online method find that they are unable to pay for their pending order because it says the item is out-of-stock.

They would receive the following message when attempting to make payment:

“Sorry, (product) is no longer in stock so this order cannot be paid for. We apologize for any inconvenience caused.”

When the customer placed their order, the item’s inventory count was descreased appropriately from 1 to 0.  This is obviously a bug in WooCommerce since the item should not need to be in stock in order for the customer to pay for their order.

The Code to Fix “Can’t Pay for Order Because Out of Stock”

In order to fix this issue, place the following code into your theme’s functions.php file.

How It Works

What this code does is hook into the WooCommerce function of checking to see if a product is in stock.  If if detects that you are on the order-pay URL, it overrides it to say that the product is in stock so that the customer may proceed with their payment.

 

0
0
vote
Article Rating
Subscribe
Notify of
guest
6 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments
Matthew Willson
Matthew Willson
1 year ago

Thanks, really helped

Gion
Gion
10 months ago

Thanks for sharing the code, Nathan! However, it seems recent updates in WooCommerce brought the problem back. I thought it might be interference from another plugin. However, on a fresh install of WordPress 5.2.2 with WooCommerce 2.7.0 the code mentioned in the article doesn’t fix the problem anymore. I tried using the “woocommerce_pay_order_product_in_stock” filter instead but either my code is bad or it’s simply not the right way. Any ideas?

che
che
10 months ago

I’ve found WC order workflow to be frustrating in many ways in regards to payment and fulfillment being one combined process. These are separate on most other platforms. Looking for this same solution since I offer my customers payment terms, but code did not work for me. Any suggestions?