[英]Add custom text under order details on WooCommerce My account view order pages
I need to add some custom text under the Order Details section of the WooCommerce view-order page. 我需要在WooCommerce查看顺序页面的“订单详细信息”部分下添加一些自定义文本。
My goal here is to add some additional instructions: 我的目标是添加一些其他说明:
To cancel your license within the 30 day trial period click REFUND MY ENTIRE ORDER
要在30天的试用期内取消许可证,请单击“退款我的全部订单”
How might I accomplish this? 我该怎么做?
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>' );
}
}
Code goes in function.php file of your active child theme (or active theme). 代码进入您的活动子主题(或活动主题)的function.php文件中。 Tested and works.
经过测试和工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.