Home » WooCommerce: View Thank You Page @ Order Admin

WooCommerce: View Thank You Page @ Order Admin

by Tutor Aspire

I’ve been testing for over an hour but finally I found a way to make this work. When you are in “Edit Order” view under WordPress Dashboard > WooCommerce > Orders, there is a dropdown of “Order actions”: “Email invoice”, “Resend new order notification”, etc.

A major problem I’ve always had while troubleshooting or working on the WooCommerce thank you page was that I had to build that URL by hand in order to view it again or to avoid placing yet another test order (it follows the format e.g. https://example.com/checkout/order-received/214008/?key=wc_order_aHB6YrmLOZIKP).

Well, from today, you can access that order thank you page URL directly from the “Order actions” dropdown. Enjoy!

Here’s our brand new order action: “Display thank you page”. Simply select and then click on the right arrow, and you will be automatically redirected to the order’s thank you page!

PHP Snippet: Add “View Thank You Page” to “Order actions” @ Edit Order WP Admin Pages

Note: remove the $order->has_status() check if you wish this to appear for ALL order statuses.

/**
 * @snippet       View Thank You Page @ Edit Order Admin
 * @how-to        Get tutoraspire.com FREE
 * @author        Tutor Aspire
 * @compatible    WooCommerce 6
 * @donate $9     https://tutoraspire.com
 */

add_filter( 'woocommerce_order_actions', 'tutoraspire_show_thank_you_page_order_admin_actions', 9999, 2 );

function tutoraspire_show_thank_you_page_order_admin_actions( $actions, $order ) {
if ( $order->has_status( wc_get_is_paid_statuses() ) ) {
$actions['view_thankyou'] = 'Display thank you page';
}
return $actions;
}

add_action( 'woocommerce_order_action_view_thankyou', 'tutoraspire_redirect_thank_you_page_order_admin_actions' );

function tutoraspire_redirect_thank_you_page_order_admin_actions( $order ) {
$url = $order->get_checkout_order_received_url();
add_filter( 'redirect_post_location', function() use ( $url ) {
return $url;
});
}

You may also like