skip to Main Content

I need to add some content to the Wooommerce thankyou.php. In the past, I had added it by overriding it in the child theme, but this is not an option any longer so I need to add the content through an action hook somehow. How can I do this? The content I need to add is

 <div class ="text"><p>Lorem ipsum <strong><?php echo $order->get_order_number(); ?></strong>.</p>
    <h3>
    Headline
</h3>
            <?php if ( 'paypal' == $order->get_payment_method() ){
                printf( __("<p>Lorem ipsum <strong>%s</strong>.</p>", "woocommerce"),  $order->get_billing_email() );
}           
                  else {printf( __("<p>Lorem ipsum 2 <strong>%s</strong>.</p>", "woocommerce"), $order->get_billing_email() );
}               ?>

<h3>
    Headline
</h3>
<p>
     Lorem ipsum
</p>
 </div>

How can I add this content to the thankyou.php and remove the default "Thank you, your order has been received" sentence plus order overview table at the top?

2

Answers


  1. Havent tried it, but this might work:

    function add_text_thankyou($text,$order){
    $html = '';
        if ( 'paypal' == $order->get_payment_method() ){
           $html .= '<your text>';
        }
     return $html;
    }
    add_filter( 'woocommerce_thankyou_order_received_text','add_text_thankyou',20,2);
    
    Login or Signup to reply.
  2. You can use woocommerce action hooks woocommerce_thankyou_. For further information on how to use it you can view this link. Hope it helps 🙂

    https://www.webroomtech.com/add-custom-content-to-woocommerce-thank-you-page/

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search