In this post we will explain you how to use custom thank you page in WooCommerce, So the customer will redirect your specific thank you page after purchase completed. For achieve this task we can use WooCommerce hook wc_custom_redirect_after_purchase.
Redirect Customer to Custom Thank you Page in WooCommerce
First you need to create custom thank you page in WordPress admin. Just go to Pages->add new link to create new custom page, Add your desired content on this page which you want to show customer after successful purchase done.
Now publish this page and you got page view link. We can place this page link on WooCommerce hook function.
Add below WooCommerce custom page code in you child theme function.php file.
1 2 3 4 5 6 7 8 9 10 |
function wc_custom_redirect_after_purchase() { global $wp; if ( is_checkout() && ! empty( $wp->query_vars['order-received'] ) ) { wp_redirect( 'http://www.example.com/thank-you-for-your-purchase/' ); exit; } } add_action( 'template_redirect', 'wc_custom_redirect_after_purchase' ); |
Place your created custom thank you page link in this code under wp_redirect function. After doing this default WooCommerce thank page will be replaced by you created custom page.