admin管理员组文章数量:1130349
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.phpadd 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.
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.phpadd 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.
本文标签: woocommerce offtopicDifferent files for order details
版权声明:本文标题:woocommerce offtopic - Different files for order details 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749225101a2335534.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论