admin管理员组

文章数量:1193979

I would like to add a text in the checkout page in this part:

I tried to use this hook:

function wh_test_1($order_id) { //<--check this line

    //create an order instance
    $order = wc_get_order($order_id); //<--check this line

    $paymethod = $order->payment_method_title;
    $orderstat = $order->get_status();
    echo "teste";
}

but the word "teste" appear in this part:

Somone can help me?

I would like to add a text in the checkout page in this part:

I tried to use this hook:

function wh_test_1($order_id) { //<--check this line

    //create an order instance
    $order = wc_get_order($order_id); //<--check this line

    $paymethod = $order->payment_method_title;
    $orderstat = $order->get_status();
    echo "teste";
}

but the word "teste" appear in this part:

Somone can help me?

Share Improve this question asked Aug 23, 2022 at 18:39 Rodrigo FrancoRodrigo Franco 31 bronze badge
Add a comment  | 

1 Answer 1

Reset to default 2

You have two options. You can use the hook woocommerce_before_thankyou hook to add some html before "Obrigado. Seu pedido foi recebido" or you can replace the that thankyou text with any html you want with the hook woocommerce_thankyou_order_received_text

If you want to use woocommerce_before_thankyou (NOTE: this hook will fire also on failed orders, but you can check inside the hook if the order is failed with the $order_id):

function test_hook_before_thankyou($order_id) {
    echo "teste";
}
add_action( 'woocommerce_before_thankyou', 'test_hook_before_thankyou' );

If you want to replace that text with the hook woocommerce_thankyou_order_received_text:

function test_hook_replace_thankyou ( $thank_you_msg, $order_obj) { /* here you have the full order object, no only the id */

    $thank_you_msg =  'This is your new thank you message';
    $thank_you_msg .=  '<br><b>You can add html too</b>';
    return $thank_you_msg;
}
add_filter( 'woocommerce_thankyou_order_received_text', 'test_hook_replace_thankyou' );

本文标签: pluginsHow to add a text in the checkout page woocomerce