在WooCommerce我的帐户查看订单页面上的订单详细信息下添加自定义文本
问题描述:
我需要在WooCommerce查看顺序页面的订单详细信息"部分下添加一些自定义文本.
I need to add some custom text under the Order Details section of the WooCommerce view-order page.
我在这里的目标是添加一些其他说明:
My goal here is to add some additional instructions:
要在30天的试用期内取消许可证,请单击退款我的全部订单"
To cancel your license within the 30 day trial period click REFUND MY ENTIRE ORDER
我该怎么做?
答
尝试以下操作以在查看订单"页面中显示自定义文本:
Try the following to display a custom text in "View Order" pages:
add_action('woocommerce_order_details_after_order_table', 'action_order_details_after_order_table', 10, 4 );
function action_order_details_after_order_table( $order, $sent_to_admin = '', $plain_text = '', $email = '' ) {
// Only on "My Account" > "Order View"
if ( is_wc_endpoint_url( 'view-order' ) ) {
printf( '<p class="custom-text">' .
__("To cancel your license within the 30 day trial period click on %s" ,"woocommerce"),
'<strong>"' .__("Refund my entire order", "woocommerce") . '"</strong>.</p>' );
}
}
代码进入您的活动子主题(或活动主题)的function.php文件中.经过测试,可以正常工作.
Code goes in function.php file of your active child theme (or active theme). Tested and works.