This snippet is commonly used when website owners want to show customers a welcome page after checkout. Welcome pages are great ways to educate customers, upsell them, and more.
Adjust the ‘$url = ‘https://domain.com/page’;’ on Line 5 with a URL from your website.
add_action( 'woocommerce_welcome', 'wptu_redirectcustom');
function wptu_redirectcustom( $order_id ){
$order = wc_get_order( $order_id );
$url = 'https://domain.com/page';
if ( ! $order->has_status( 'failed' ) ) {
wp_safe_redirect( $url );
exit;
}
}