【问题标题】:Add custom text under order details on WooCommerce My account view order pages在 WooCommerce 我的帐户查看订单页面的订单详细信息下添加自定义文本
【发布时间】:2019-03-01 16:57:15
【问题描述】:

我需要在 WooCommerce 查看订单页面的订单详情部分下添加一些自定义文本。

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

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

我该如何做到这一点?

【问题讨论】:

    标签: php wordpress woocommerce endpoint account


    【解决方案1】:

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

    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 文件中。经过测试并且可以工作。

    【讨论】:

      猜你喜欢
      • 2023-03-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-06-21
      • 2015-12-10
      • 1970-01-01
      • 1970-01-01
      • 2017-01-20
      相关资源
      最近更新 更多