The below code allows you to redirect to a custom page after the user has successfully completed a purchase when using the WooCommerce plugin. Simply add the below code to the active child theme’s function.php and replace the URL in the function wp_redirect() with the desired page.
<?php
add_action( 'template_redirect', 'cxc_woocommerce_redirect_after_purchase' );
function cxc_woocommerce_redirect_after_purchase() {
global $wp;
if ( is_checkout() && !empty( $wp->query_vars['order-received'] ) ) {
wp_redirect('https://codexcoach.com/');
exit;
}
}
?>
Was this article helpful?
YesNo