I need a bit of help with woocommerce customization. I need to redirect the user after the order is completed to a custom page, I’m using this code in my plugin but seems not working
public function redirect_customer_after_order()
{
if( is_checkout() && isset( $wp->query_vars['order-received'] ) ){
wp_safe_redirect( site_url( 'riepilogo-ordine' ) );
exit;
}
}
add_action( 'template_redirect', array( $this, 'redirect_customer_after_order' ) );
I’ve tried to place an order but my custom woocommerce elementor page will be not displayed and I will see the default woocommerce thank you page. Also I’ve noticed that this hook will be ignored
remove_action( 'woocommerce_order_details_after_order_table', 'woocommerce_order_again_button' );
It will simple remove the order again button, I’ve placed it inside the __construct()
of my plugin. How I can fix these two issues?
2
Answers
Correct Hook: Use woocommerce_thankyou instead of template_redirect for more reliable redirection within WooCommerce
Correct Hook Priority: Use a higher priority to ensure your code runs after WooCommerce’s
Please Try this code for redirect custom thank you page
`