Skip to content
Advertisement

WooCommerce action hook to redirect to new page on order failed

I want to redirect to a custom wordpress page if a customers woocommerce order fails.

I have found and implemented the following code which redirects to a new page upon payment success.

Is it possible to add to this code, so a failed order is sent to another specific url ?

JavaScript

Advertisement

Answer

Based on the code you have, you can use $order->has_status( 'failed' )

So you get:

JavaScript

Code goes in functions.php file of the active child theme (or active theme). Tested and works in WordPress 5.8.1 & WooCommerce 5.8.0

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement