There are numerous reasons why an order may fail. The most common reason is an error in the payment processor. This could be a one time thing or maybe a glitch with the payment processor. In any case, it would be good to follow up with the customer. It would be a huge shame if you didn’t do anything as the customer was already in the checkout/buying process and didn’t get to complete their order.
This could be one of the easiest ways to retrieve lost revenue.
Setting up a failed order notification in WooCommerce
WooCommerce automatically sets an order to failed when something goes wrong. With a simple code snippet you can send yourself an email or push notification, so you can follow up as soon as possible with the customer. In my experience that would be an amazing customer experience, right?
Setting up a failed order email notification
There is no user interface for this available in WooCommerce, so I’m posting a code snippet you can use. With this code snippet the functionality will be added directly to your site without the use of a plugin. It will automatically send simple email notifications with a short message to the admin email notifying him/her that there has been a failed order.
Setting up a failed order push notification
Setting up a push notification is a bit more difficult than setting up an email notification. It requires your site be integrated with a service to do the push notification and thus requires a bit more setup. In this example, I will show you how you can send a push notification in combination with Pushover. If you haven’t set up an account yet, you can register at their site. Registration is free and so is the app you need to install on your smartphone. After the 7 days free trial, they require you to buy the smartphone app for a lifetime usage for up to 7500 messages per month (if you go above that you can get a monthly plan).
When you’ve set up your account, you will need two things from that account:
1) Your user key
2) Application key
The user key can be found directly in your dashboard when you go to Pushover.com and are logged in. To get an application key, you’d first need to register a new application. You can do this also from the initial dashboard.
When you’re registering a new application, you need to fill out the fields as seen in the screenshot above. As type you can enter ‘website’, description, url, and icon can be any values you’d like, they’re optional values.
Setting up the notification
When you’ve retrieved the user and application keys, you can use the code snippet below. Copy/paste the contents to your (child) theme’s functions.php and replace the
} to your keys.
This code snippet will send the push notification as soon as an order goes to the failed orders status. It will send a link to the related order within the notification so you can view the order immediately.
Setting up the app
Make sure to download the Pushover notifications app from the app store on your iOS or Android smartphone and log in with your account. Pushover will recognize and register your phone in the website’s dashboard. You can send a test notification from there to see if everything is working fine.
That’s it for setting up a push notification when an order goes to the failed order status.
Now that you’re getting notifications when an order fails, it’s easy to follow up with the customer. As mentioned earlier, this could be the easiest way of retrieving lost revenue since the customers were already late in the buying process when something went wrong. Having someone reach out to you and ask how they can help you further can be a great customer experience and will not be forgotten.
Get our best WooCommerce advice!
Delivered directly to your inbox