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');

 

Categories

Related Blogs

How To Add Sub Menu In WordPress Admin Panel

How to add sub-menu in WordPress admin panel – In this post we see how we can add custom sub-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.

Create WooCommerce Orders Programmatically

To create WooCommerce orders programmatically in WordPress, you can use the `wc_create_order()` function provided by WooCommerce. This function allows you to create orders and add products to them. Make sure you have WooCommerce installed and activated in your WordPress environment. Here’s a step-by-step guide: