You need to look at WooCommerce plugin includes/wc-template-hooks.php
core file (line 259):
add_action( 'woocommerce_view_order', 'woocommerce_order_details_table', 10 );
As you can see, the function woocommerce_order_details_table()
is hooked in. So now let's find this function that is located in includes/wc-template-functions.php
core file (starting line 2584).
As you will see this hooked function call the template file order/order-details.php
.
So now you can make some changes:
1). Overriding the template file order/order-details.php
via your active child theme or theme as explained in this documentation.
Note: The template file order/order-details.php
is also used in Order received (thankyou), so take care to target your changes using the following condition:
// For view order
if ( is_wc_endpoint_url( 'view-order' ) ) {
// Here your changes
}
// For other cases
else {
// Here keep the original code
}
2). Or/and you could also remove this hooked function to replace it by your own custom function, with something like:
remove_action( 'woocommerce_view_order', 'woocommerce_order_details_table', 10 );
add_action( 'woocommerce_view_order', 'custom_order_details_table', 10 );
function custom_order_details_table( $order_id ) {
if ( ! $order_id ) {
return;
}
// Here below add your own custom code
}
You can also call your own custom template in that custom function, that will be used exclusively in order view endpoint...
Related: WooCommerce action hooks and overriding templates
WooCommerce Documentations: