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

 

Share This On :

Leave a Comment

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