Pawan Kumawat

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

Jquery Form Validator With User Name Exist User Email Exist

To implement jQuery Form Validator with the specified validation rules, including required, minlength, email, equalTo, custom validation, confirm password, username pattern, email existence in the database in WordPress, and username with no numeric value, you’ll need to combine client-side validation using jQuery Form Validator with server-side validation using PHP and WordPress functions.

Cron Job WordPress (WP-Cron)

What Is Wordpress Cron Job? Wordpress Cron Job is how WordPress handles scheduling time-based tasks in WordPress.“Cron” Means the cron time-based task scheduling system which is available on UNIX systems.

Shortcodes included with WooCommerce

WooCommerce comes with several shortcodes that you can use to display various elements and functionalities on your WordPress website. These shortcodes allow you to customize the appearance and layout of your WooCommerce store. Here are some of the essential shortcodes included with WooCommerce: