在WooCommerce我的帐户查看订单页面上的订单详细信息下添加自定义文本

问题描述 投票:0回答:1

我需要在WooCommerce视图订单页面的“订单详细信息”部分下添加一些自定义文本。

我的目标是添加一些额外的说明:

要在30天试用期内取消许可,请单击“退款我的整个订单”

我怎么能做到这一点?

php wordpress woocommerce endpoint account
1个回答
0
投票

请尝试以下操作在“查看订单”页面中显示自定义文本:

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文件中。经过测试和工作。

© www.soinside.com 2019 - 2024. All rights reserved.