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 7
 */
 
add_action( 'woocommerce_thankyou', 'bbloomer_add_content_thankyou' );
 
function bbloomer_add_content_thankyou() {
   echo '<p>Some HTML content!</p>';
}

Mini-Plugin: Business Bloomer WooCommerce Add Content To The Thank You Page

You don’t feel confident with coding? You don’t want to purchase yet another bloated, expensive plugin? Great!

Business Bloomer WooCommerce Add Content To The Thank You Page is a mini WooCommerce plugin, without the usual hassles. One feature. Lifetime license. No annoying subscriptions. 1 plugin file. A few lines of code. No banners. No up-sells. No WP notifications. Use it on as many websites as you like. Lifetime support. 1-page documentation. Super simple settings.

Speaking of which, here’s a screenshot of the settings:

Quick demo:

As you can see the plugin is straight forward. Install it, define the content you want to show via the WP editor, choose the position, and save. Simple – your custom content will now display in the WooCommerce Thank You Page!

Where to add custom code?

You should place custom PHP in functions.php and custom CSS in style.css of your child theme: where to place WooCommerce customization?

This code still works, unless you report otherwise. To exclude conflicts, temporarily switch to the Storefront theme, disable all plugins except WooCommerce, and test the snippet again: WooCommerce troubleshooting 101

Related content

  • WooCommerce: Redirect to Custom Thank you Page
    How can you redirect customers to a beautifully looking, custom, thank you page? Thankfully you can add some PHP code to your functions.php or install a simple plugin and define a redirect to a custom WordPress page (as opposed to the default order-received endpoint). This is a great way for you to add specific up-sells, […]
  • WooCommerce: How to Add a Custom Checkout Field
    Let’s imagine you want to add a custom checkout field (and not an additional billing or shipping field) on the WooCommerce Checkout page. For example, it might be a customer licence number – this has got nothing to do with billing and nothing to do with shipping. Ideally, this custom field could show above the […]
  • WooCommerce: Add Tracking Code / Script @ Thank You Page
    How do you add a tracking code to the WooCommerce Thank You Page? Well, with a simple snippet (and no plugin) you can! No matter whether you’re using Google AdWords, Facebook or other forms of marketing – the Thank You Page is such an important section of an ecommerce store and needs some TLC!
  • WooCommerce: Apply Coupon Programmatically if Product @ Cart
    Users can manually enter a coupon code, refresh the Cart and see their discount apply… or you can do that automatically (or “programmatically” as we say in the dark web) when a user adds a product to the WooCommerce Cart 🙂 All you’ve got to do is creating a coupon, and then a PHP function […]
  • WooCommerce: Remove Link to Product @ Order Table
    There is a slightly annoying thing on the WooCommerce Thank-You Page and WooCommerce emails. Users looking at the order table can actually click on the Products they just purchased and abandon the page before taking the action you want them to take (see image below). So, I coded a simple PHP snippet to remove such […]

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. Follow @rmelogli

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

  1. Do you know if this will break Cart Flows thank you pages or that it just affects general thank you pages.

    1. Not sure, this looks for a “hook” that is used on the default WooCommerce Thank You page. So, if Cart Flows custom thank you page also includes this same hook, it will show the content – otherwise you need custom work. Makes sense?

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

    1. Great!

  3. 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!

  4. 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!

  5. 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.
    TIA.

    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!

  6. 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!

  7. 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

  8. 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

  9. Awesome! Still working on 3.2.1

  10. 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!

  11. 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 🙂

  12. 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!

  13. 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!

  14. 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

  15. 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!
    Tim

    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

        Tim

        1. Awesome to hear that Tim 😀

  16. 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

  17. 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

    Winston

    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!

  18. 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?
    Thanks!

    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!
        Nina

        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 🙂

  19. 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
    Ronald

    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!

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

    Thanks!
    Mike

    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!

          ~R

  21. 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!

  22. 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!

  23. 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!

  24. in which file this snippet need to add?

    main …… functions.php

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

  25. 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?

  26. 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!

  27. Thank you for this!

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

    regards
    Johannes

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

      1. hm, does not work for me…

        regards
        Johannes

        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/

  28. Hey,

    Me again…where do I add this?.

    1. You can add them to your template functions.php file 🙂

Questions? Feedback? Customization? Leave your comment now!
_____

If you are writing code, please wrap it like so: [php]code_here[/php]. Failure to complying with this, as well as going off topic or not using the English language will result in comment disapproval. 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 the Business Bloomer Club to get quick WooCommerce support. Thank you!

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