I'm developing a theme for woocommerce website. My problem is that to show order details on my account and thank you page, woocommerce only has the following template file:
/wp-content/plugins/woocommerce/templates/order/order-details.php
How to create two different template files for thank you page and my account page to show order details.
I'm developing a theme for woocommerce website. My problem is that to show order details on my account and thank you page, woocommerce only has the following template file:
/wp-content/plugins/woocommerce/templates/order/order-details.php
How to create two different template files for thank you page and my account page to show order details.
Share Improve this question edited Oct 29, 2018 at 8:46 Janaka Dombawela asked Oct 29, 2018 at 8:17 Janaka DombawelaJanaka Dombawela 1035 bronze badges1 Answer
Reset to default 1- 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.