In this article we will go into Pending payment orders and the Hold stock setting in WooCommerce. It might seem basic, but there are more to it that you might be aware of.
For stock management to work the product(s) you sell need to have the setting stock management at product level enabled.
When an order is placed in WooCommerce it gets the status Pending payment. At this point you don’t see any inventory change in the order notes. Which is how WooCommerce handles the order statuses.
Stock quantity changes are added to the order notes once the order is considered paid. Read more about WooCommerce order statuses here.
Even though the stock quantity is not yet reduced, the way WooCommerce operates is that it actually reserves/holds the products in an order when the order is placed. This is so that a product can’t be sold out while a customer’s payment is being processed. You can control this with the help of the WooCommerce Hold stock setting. If you for instance enter 5 minutes in the Hold stock (minutes) field, that is how long the product is held while awaiting order payment.
If no payment is received within these 5 minutes the order will be cancelled and the product will be available for purchase again. Please note that this only applies to orders with the Pending payment status, not On hold. When setting the amount of minutes stock will be held you need to consider setting enough time to actually allow a customer the time to finish their order. You also need to consider not setting it too long, so that it remains unavailable for others if the customer decides to not complete the order.
Changed pending payment orders
When a customer places an order in WooCommerce a Pending payment order will be created as we mentioned earlier. If the customer for some reason doesn’t complete the order at this point, it will remain in pending payment status. An example can be if the customer backs out of payment or misses a required field.
If the customer returns to complete the order before the session has expired and without changes, the same order will be used. However, if the customer makes any changes, or their session has expired, a new order will be created and used instead. For example, if the customer adds or removes products. Adds or removes a coupon. Switches shipping or payment methods. Then a new order will be created and used instead.
This will cause two orders from the same customer to exist in WooCommerce that also can have the same transaction-ID from the payment provider. This in itself is not a problem, other than it can be confusing, since the customer has only been charged for the Processing order. It can however cause some unforeseen issues. For instance, a discount coupon limited to one (1) use can wrongfully be deemed as no longer valid.
Discount coupons wrongfully claimed to have already been used.
This error can occur with coupons limited to one (1) use and if the customer has made changes to a Pending payment order. Triggering the creation of a new order, as we wrote above.
In that case the discount coupon is tied to the first Pending payment order until that order is Cancelled. At which point WooCommerce releases the coupon for use again. The time it takes WooCommerce to automatically cancel an order is dependent on the Hold stock setting mentioned above. You, the merchant, can also cancel the order manually to free up the coupon for use again.
Why isn’t the order set to Cancelled?
If an order that isn’t finalized by the customer isn’t automatically set to Cancelled after the time set in the Hold stock setting has expired, it most likely means that your website has an issue with WP-cron. WP-Cron is how WordPress handles scheduling time-based tasks in WordPress. You can read more about this at wordpress.org.
Note that WP-cron can be turned off in WordPress, but that system cron can still run on the server. So advise your web developer or your host regarding this.