Redirect to custom page after success purchase. Issue
-
Hello.
I need automatically create an account during checkout.
And I need redirect to custom thank you page after success purchase, but me redirected to login page ( /wp-login.php ).
I am not logged in when during purchase.My woocommerce settings:
https://www.screencast.com/t/FLljXVZt9
https://www.screencast.com/t/bry5nU6kI try this code in functions.php file:
add_action( 'woocommerce_thankyou', 'redirect_to_thankyou_page'); function redirect_to_thankyou_page( $order_id ){ $order = new WC_Order( $order_id ); $url = home_url('/success/'); if ( $order->status != 'failed' ) { wp_redirect($url); exit; } }
and
add_action( 'template_redirect', 'woo_custom_redirect_after_purchase' ); function woo_custom_redirect_after_purchase() { global $wp; $ty_page = home_url('/success/'); if ( is_checkout() && !empty( $wp->query_vars['order-received'] ) ) { wp_redirect($ty_page); exit; } }
But still redirected to /wp-login.php page
Wordpress version: 5.4
WooCommerce version: 4.0.1Thanks in advance
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Redirect to custom page after success purchase. Issue’ is closed to new replies.