亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

帶有條件的訂單明細表下的文本

帶有條件的訂單明細表下的文本

PHP
神不在的星期二 2022-01-14 15:39:46
我想在我的帳戶頁面的訂單詳細信息表下添加一個文本,如下面的屏幕截圖所示,但如果訂單狀態更改為完成,我希望將此文本更改為另一個文本。這是我用來顯示文本的內容,但如果狀態從任何狀態更改為完成,我不能有條件地將文本更改為另一個文本。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>' );    }}我只需要在訂單狀態完成后將此消息更改為另一條消息。
查看完整描述

1 回答

?
幕布斯7119047

TA貢獻1794條經驗 獲得超8個贊

使用以下代碼更改您的上述代碼 -


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' ) ) {

        if( $order->get_status() == 'completed' ){ // for completed status

            printf( '<p class="custom-text">' .

        __("Your order completed message goes here %s" ,"woocommerce"),

        '<strong>"' .__("Refund my entire order", "woocommerce") . '"</strong>.</p>' );

        }elseif($order->get_status() == 'cancelled'){ // for cancelled status

           printf( '<p class="custom-text">' .

        __("Your order cancelled message goes here %s" ,"woocommerce"),

        '<strong>"' .__("Refund my entire order", "woocommerce") . '"</strong>.</p>' );

        }else{ // for rest statuses

            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>' );

        }

    }

}


查看完整回答
反對 回復 2022-01-14
  • 1 回答
  • 0 關注
  • 139 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號