Here is what you need to do to have a custom order received page (thank you page) working with One Click Upsells.
1. Create a simple page, customize it as you wish and insert a [wc_1cu_order_details] shortcode inside it. This shortcode will display the order details properly.
2. First option: Use our Custom Thank You Pages plugin for WooCommerce that can handle the redirection for you automatically.
Second option: Otherwise, add the code from below to your theme’s functions.php:
1 2 3 4 5 6 7 8 9 | function gb_wc_1cu_redirect_to_cty( $order_id ) { if( mb_strpos( $_SERVER['REQUEST_URI'], '/your-thank-you-page-slug/' ) !== 0 ) { $order = wc_get_order( $order_id ); echo '<script type="text/javascript">window.location.href="/your-thank-you-page-slug/?key=' . $order->get_order_key() . '";</script>'; } } add_action( 'woocommerce_thankyou', 'gb_wc_1cu_redirect_to_cty', 999 ); |
This code will perform a redirection from the default /order-received/ thank you page to your custom “thank you” page.
Important: But you need to change the “/your-thank-you-page-slug/” in the code above to the actual slug of your custom thank you page.