Create Custom Menu in WordPress Dashboard
Complete tutorial on create custom menu in wordpress dashboard. Discover practical examples, implementation tips, and expert advice for WordPress and WooCo
Read More โCustomize WooCommerce thank you page using woocommerce_thankyou action hook executed after order placement. Add custom HTML text with echo statements for personalized messages, load dynamic content from WordPress pages using get_post with page ID and post_content property, display related products, popular items, or special offers with WooCommerce shortcodes, show personalized recommendations based on order, include upsell opportunities or referral programs, provide additional order information or support links, create memorable post-purchase experience, and enhance customer engagement with targeted content on order confirmation page encouraging repeat purchases.
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');
Search our archives or reach out to our team for solutions and expert advice.