WooCommerce: Add Content to the Thank You Page

A client of mine wanted to add some text to the thank you page, the page that customers see after they place an order via the default WooCommerce Checkout page.

In this case scenario, they wanted to add a special coupon discount in order to entice buyers to go back to the website and buy again. Enjoy!

WooCommerce: add text to the thank you page

PHP Snippet: Add Content to the WooCommerce Thank You Page

 * @snippet       WooCommerce add text to the thank you page
 * @how-to        Get CustomizeWoo.com FREE
 * @author        Rodolfo Melogli
 * @testedwith    WooCommerce 4.5
add_action( 'woocommerce_thankyou', 'bbloomer_add_content_thankyou' );
function bbloomer_add_content_thankyou() {
   echo '<p>Some HTML content!</p>';
Was this article helpful?

Where to add custom code?

You should place PHP snippets at the bottom of your child theme functions.php file and CSS at the bottom of its style.css file. Make sure you know what you are doing when editing such files - if you need more guidance, please take a look at my guide "Should I Add Custom Code Via WP Editor, FTP or Code Snippets?" and my video tutorial "Where to Place WooCommerce Customization?"

Does this snippet (still) work?

Please let me know in the comments if everything went as expected. I would be happy to revise the snippet if you report otherwise (please provide screenshots). I have tested this code with Storefront theme, the WooCommerce version listed above and a WordPress-friendly hosting.

If you think this code saved you time & money, feel free to join 17,000+ WooCommerce Weekly subscribers for blog post updates and 250+ Business Bloomer supporters for 365 days of WooCommerce benefits. Thank you in advance!

Need Help with WooCommerce?

Check out these free video tutorials. You can learn how to customize WooCommerce without unnecessary plugins, how to properly configure the WooCommerce plugin settings and even how to master WooCommerce troubleshooting in case of a bug!

Rodolfo Melogli

Business Bloomer Founder

Author, WooCommerce expert and WordCamp speaker, Rodolfo has worked as an independent WooCommerce freelancer since 2011. His goal is to help entrepreneurs and developers overcome their WooCommerce nightmares. Rodolfo loves travelling, chasing tennis & soccer balls and, of course, wood fired oven pizza.

72 thoughts on “WooCommerce: Add Content to the Thank You Page

  1. Used a link ‘Click to go to My Account’ as below. Excellent – Thanks.

    1. Great!

  2. Hi, once the client purchases the virtual meditaion on my website, on the order received page he should see a link which he can click and access the meditaion immediately. For all payment methods (paypal and razorpay) how do i do that. using woo commerce

    1. Hello Rima, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!

  3. Could you have it so a message is displayed if a certain product is ordered?

    1. Hey Dan, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!

  4. How can I add custom field after ‘Billing Address’ details?
    Currently I’m using ‘woocommerce_order_details_after_order_table’ but I want further down.

    1. Darshan, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!

  5. Hi Rodolfo,

    Thanks for the great piece of code! just what I was looking for, I don’t have the most up to date version of WC, but can confirm that this work on v3.4.4!

    Keep up the great work!

    1. Awesome!

  6. How would you add a link within this content? Can you please give me the code for this?

    1. Hello Mark, thanks so much for your comment! Yes, this is possible – unfortunately this is custom work and I cannot provide a complementary solution here via the blog comments. Thanks a lot for your understanding! ~R

  7. Thank you. I would like show the cross sell products on the thankyou page with this coupon. How can we achieve this?

    1. Hey Kevin, thanks so much for your comment! Yes, this is possible – but unfortunately this is custom work and I cannot provide a complementary solution here via the blog comments. Thanks a lot for your understanding! ~R

  8. Awesome! Still working on 3.2.1

  9. Wow worked perfectly. Putting the number 5 in put it exactly where I wanted it. Without it being in apostrophes ‘5’ btw. Why couldn’t I put the number 1 or 10? No need to answer as that may be lengthy but just curious.

    1. Awesome πŸ™‚ You should take a look at the add_action syntax and learn more about the “priority”. Hope this helps!

  10. Hi, thank for your advice, it works, i just have a problem with a font, that doesnΒ΄t recognize letter in slovak. It show some marks AKO DARοΏ½EK OD NοΏ½S 10% ZοΏ½AVA!
    How can I change that?

    1. Hey Dasken, thanks for your comment! You should take a look at https://stackoverflow.com/questions/12699037/how-to-display-special-characters-in-php, it should help πŸ™‚

  11. hello, thanks for the write-up but hey am trying to rewrite the wordings on my order-received page but I cant seem to find the page

    This is the page i am trying to edit https://i.snag.gy/D6Q3tr.jpg

    Can you help me?

    1. Hey Ifeanyi, thanks so much for your comment. You can “translate” that string by using this: https://businessbloomer.com/translate-single-string-woocommerce-wordpress/. Hope this helps!

  12. Where do I add these codes?

    1. Hey Jack, thanks for your comment! You can place this in your child theme’s functions.php file – if you need more guidance, please take a look at this video tutorial: https://businessbloomer.com/woocommerce-customization-hangout/. Hope this helps!

  13. Hi Rodolfo,

    I am having a problem with my woo as right now, the email confirmations and the check out shows the said notes done by a previous developer but I can’t seem to find where they can be modified, edited or removed.

    1. Hey Wendell, thanks for your comment! Yes, this is possible – but unfortunately this is custom work and I cannot provide a complementary solution here on the blog. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding! ~R

  14. Hey, thanks for the code! it helps me a lot!
    I just need to know one more thing.
    Right now, the added content is on the bottom of the page, but i need it at the top of the page.
    How can I change that?

    Thanks in advance!

    1. Tim, thanks a million for your comment! Try adding a “5” here:

      add_action( 'woocommerce_thankyou', 'bbloomer_add_content_thankyou', 5 );

      Let me know πŸ™‚

      1. Thank you so much! It worked!
        Just need to put the 5 inbetween ‘5’ as well.

        best regards


        1. Awesome to hear that Tim πŸ˜€

  15. Hey! Thank you so much for this! I added to the code and it works, but it adds it to the BOTTOM of the thank you page, instead of right under the first thank you text as in your screenshots. I’d love to have it at the top like that–is there a reason mine is getting added to the very bottom (below all the order details?) I feel like people won’t see it there. Thanks!

    1. Hey Meg thanks so much for your comment! See this other comment reply and let me know if this works for you too: https://businessbloomer.com/woocommerce-add-text-thank-page/#comment-19210

  16. Hi Rodolfo:

    Nice site.

    Please how could one edit the “order received” page https://prnt.sc/d4za0m

    (I’ll be grateful if you could show step-by-step how you get to the part where you see the code to edit (for non-experts like me!)

    Thank you


    1. Hey Winston, thanks so much for your feedback! It seems you just want to change some strings of text… in this case I recommend to do this: https://businessbloomer.com/translate-single-string-woocommerce-wordpress/. Let me know!

  17. Hello Rodolfo,
    could you let me know how to have a certain text on the Thank you page only when chosen payment method is Paypal?

    1. Hello Nina, thanks so much for your comment πŸ™‚ I held a free class last month that covered this exact functionality: https://businessbloomer.com/customize-woocommerce-thankyou-page-tutorial. Let me know if this helps! ~R

      1. Hello Rodolfo,
        thank you very much but I am very new to coding and my PHP is limited. In your video you have another condition statement when talking about adding text based on payment type, could you let me know what the code would look like w/o another condition? So really just if chosen method is Paypal, echo …

        Thank you so much!

        1. No problem Nina! You just need to use the hook “woocommerce_thankyou_paypal”. I revised the blog anyway, and added one more snippet that should help you πŸ™‚ Let me know!

          1. Unfortunately the code did not work, I am not sure why? It still just displays the regular Woo message…

              1. Hi Rodolfo, my site is in German but the text is the German translation of the Woo default text. Screenshot: https://www.dropbox.com/s/3i1z9a10727ndkg/screenshot.JPG?dl=0

                1. Hey Nina, thanks! Is that all the content that you see on the Thank-you page? Weird, as that’s not the normal behavior of such page, you should have the order details and other information πŸ™‚ Unless you only put the first part of the page in your screenshot I believe there is some sort of error or plugin conflict there (my snippet shows a notice under the order details).

                  1. Okay, that makes sense now…I have commented out the order details in the thankyou.php because I don’t want them to show up! I need to add the custom text right below the regular Woo message…

                    1. Great πŸ™‚ Make sure you don’t comment out the part that says “do_action (….” that is halfway through that file πŸ™‚

  18. Hej Rodolfo
    On the woocommerce check out page a standard text shows ‘Thank you. Your order has been received.’ Because my client is using the danish translation of woocommerce, this text is ‘automaticly’ changed into the danish equivelant. Now my client want to have changed the text a little bit, and I am not sure where to do it. I found the original English ‘thank tou’-text in the thankyou.php, but am not sure if I should change text here.
    Thanks for your reply.
    Kind regards

    1. Hey Ronald, thank you for your comment! If you only want to translate 1 or 2 strings, you could try using this snippet: https://businessbloomer.com/translate-single-string-woocommerce-wordpress. Otherwise your plan B would be to override the template, but that’s not a good idea. Let me know!

  19. Hey, awesome code! Thanks! Is it possible to show the code only when a specific product is purchased?


    1. Hello Mike, thanks for your lovely feedback! Yes, you can use https://businessbloomer.com/solved-woocommerce-check-product-id-order/ to detect if a product has been purchased, and then apply the snippet conditionally. Let me know πŸ™‚

      1. Wow, thanks for such a quick info!

        Hmmm…ok, so I understand there is a solution, but have no idea how to implement it πŸ˜‰ Let’s say my product name is TEST and I want to say “Hey, thanks for buying the TEST product. Here is a discount code that you can use to purchase XYZ product”.
        How should the code look like and where do I put it?

        I am basically trying to upsell πŸ™‚
        Also, is there a way to redirect to a custom thank you page based on a purchase of a particular product? So again I would like a client buying the TEST product to be redirected to a Thank you page, where I can show him a discount code.

        Thank you!

        1. Hey Mike, thanks so much for your feedback and comment!

          Yes, this is all possible of course – but unfortunately this is custom development work and I cannot provide this solution on the blog.

          If you would like to get a quote for the fix, feel free to go here to get in touch.

          Thanks for your understanding!


  20. Thank you for the code, after hours of search I found this so useful code

    thanks again

    1. Thanks so much for your feedback Aleksei!

  21. Awesome, Thanks very much, been trying to work out how to do this and you’ve given me the most elegant answer!

    1. Thanks for your feedback Jamie!

  22. This is a handy snippet, thanks!

    i was just wondering is there a way to do this as a conditional based on the order total?

    ie if order >= $100 then show that coupon message on the thank you page?

    i did try and do this but cant seem to get extract the order value variable?

    1. Jay, thanks for your message! Of course, you could do something like this. You can append the Order total to the thank you page URL e.g. https://thank.you?total=120. On the thank you page, you can use PHP $_GET to do a conditional check. If $_GET[“total”]>=100 { do something }. Hope this helps!

  23. in which file this snippet need to add?

    main …… functions.php

    1. Yes Fatima, in the functions.php of your current theme. R

  24. i am able to add the new text. but i am still able to see the old default text after that i see my newly added text, is there a way i can replace the previous default text and only see the new one

    1. Hey Navo, thanks for your feedback. What text are you trying to remove?

  25. hi nice work and perfect. can i add form also instead of text. but i want to add form after order details.

    1. Thank you Eshwar! Of course, you can add any HTML via that hook. However, if you need to place such form after order details, I suggest overriding the thankyou.php file. Hope this helps!

  26. Thank you for this!

    How to add content on top of the checkout page? Can it be done in a similar way?


    1. Of coarse Johannes – just use this hook instead: add_action( ‘woocommerce_before_checkout_form’, ‘add_content’);

      1. hm, does not work for me…


        1. It has to work, as long as you’re using the whole snippet?

          // add text on top of the checkout page
          add_action( 'woocommerce_before_checkout_form', 'add_content');
          function add_content() {
          echo '<p>some HTML here</p>';
          1. I am using it exactly as mentioned but it results white page in wp.

            1. Are you using this function together with the other for the thank you page? You can’t have 2 functions with the same name. Hope this does the trick!

          2. Is it possible to have both this code for the thank you page AND the order email please?

            1. Hello Vu πŸ™‚ Of course this is possible. You can add content to the order email, take a look at my article here: https://businessbloomer.com/woocommerce-add-extra-content-order-email/

  27. Hey,

    Me again…where do I add this?.

    1. You can add them to your template functions.php file πŸ™‚

Questions? Feedback? Support? Leave your Comment Now!

If you are writing code, please wrap it between shortcodes: [php]code_here[/php]. Failure to complying with this (as well as going off topic, not writing in English, etc.) will result in comment deletion. You should expect a reply in about 2 weeks - this is a popular blog but I need to get paid work done first. Please consider joining BloomerArmada to get blog comment reply priority, ask me 1-to-1 WooCommerce questions and enjoy many more perks. Thank you :)

Your email address will not be published. Required fields are marked *