Change WooCommerce “Thank-You” Page Text

In WooCommerce you can define and adjust various pages and templates. But due to the fact that the Text which is displayed after a customer completed his order is just generated on the checkout page, it is not possible to insert text to this section. For simple use, you could use the translation, but it’s not possible to insert more complex code there. My use case was to insert some Javascript Code which displays a calculator for additional insurance.

The cool thing is, that WooCommerce offers a filter to adjust the text. Thanks to this it is possible to write a very basic plugin to adjust the text:

Plugin Name: Some WooCommerce Text Changer
Version: 1.0
Author: Alexander Bogoslawski

function AddMySctipt($text, $order) {
   return $text . "<br /><script src=''></script>";

add_filter("woocommerce_thankyou_order_received_text", "AddMySctipt", 50, 2);

Note the fourth parameter of the “add_filter” wich makes sure, that you will also get the information about the completed Order in your function.

To see the full code of the plugin see the source reporitory. I Also added some filtering for the producs and a settings page for the text. But thats another story.

Leave a Comment

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