Add Text To WooCommerce Thank You Page

To add custom text to the WooCommerce thank you page, you can use hooks and filters provided by WooCommerce. Here’s an example of how you can achieve this:

1. Open the theme’s functions.php file in your WordPress theme directory.
2. Add the following code to the file:

// Add custom text to WooCommerce thank you page
function add_custom_text_to_thankyou_page($order_id) {
    echo '<p>This is my custom text. Thank you for your order!</p>';
}
add_action('woocommerce_thankyou', 'add_custom_text_to_thankyou_page', 10, 1);

 

3. Save the changes and upload the modified functions.php file back to your server.

This code uses the `woocommerce_thankyou` action hook to add custom text to the WooCommerce thank you page. The `add_custom_text_to_thankyou_page()` function is the callback function that echoes the custom text. You can modify the content within the `<p>` tags to display your desired custom text or HTML.

After making these changes, the custom text will be displayed on the WooCommerce thank you page after an order has been placed.

Please note that the location and appearance of the thank you page may vary depending on your WooCommerce setup, theme, and any additional customization you may have made.

 

For loading content from any wordpress page dynamically we need to get post content and then place it is that function. we can also use shortcodes too. like related products, popular products ,sell products etc.

Example:

 

function AddContentThankyou() {
  $page_id = 15;
  $data= get_post( $page_id );
  echo $data->post_content;
}
add_action('woocommerce_thankyou','AddContentThankyou');

 

Related Blogs

How To Add Menu In WordPress Admin Panel

How to add menu in WordPress admin panel – In this post we see how we can add custom menu to admin sidebar. Sometimes when we on WordPress and we need to show some features or any information in admin page then we can use this code snippet to create the same.

Add Custom Taxonomy Filter on Products Dashboard.

How To Filter Products by Taxonomies in the Dashboard?

WooCommerce provide Many Product filters on admin screen , such as “Select a category”, “Filter by product type”, “Filter by stock status”.

Ultimate Guide to Custom Meta Boxes in WordPress

In WordPress, `add_meta_boxes` is an action hook that allows developers to add custom meta boxes to different post types’ edit screens. Meta boxes are additional sections on the post editor screen where you can add and display custom fields or other types of data related to the post.

Request A Quote

Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.