- Create/copy an override template file in
your-theme/woocommerce/order/order-details-thankyou.php
In functions.php
add this block of code:
function woocommerce_order_details_table_thankyou( $order_id ) {
if ( ! $order_id ) {
return;
}
wc_get_template( 'order/order-details-thankyou.php', array(
'order_id' => $order_id,
) );
}
remove_action( 'woocommerce_thankyou', 'woocommerce_order_details_table', 10 );
add_action( 'woocommerce_thankyou', 'woocommerce_order_details_table_thankyou', 10 );
This is perfectly fine way to unhook the default template file and hook your own. Now you have two template files for showing the order details, the default one order-details.php
and a new one order-details-thankyou.php
.
Btw, I hope you are aware that it is really bad practice to edit the plugin template files directly inside the plugin directory. You should always override them by copying them to you theme directory. For WooCommerce, this directory is your-theme/woocommerce/...
(omit the templates
directory). You are probably aware of this, but it doesn't hurt to be reassured.