How to Show Product Upsells at Thank You Page in WooCommerce?

Thank You page on WooCommerce can bring most conversions. It is a golden opportunity to encourage your customers to buy more. The user on the Thank You page has just become your customer. So, the possibilities are high that this customer will purchase more from your website. You can display related products below the Thank You page to make him take action. In this article, you will learn how to show product upsells at Thank You page.

You need to apply a shortcode to make this function active. However, the Thank You page is not directly available inside WordPress pages. So, you could not straight away add a shortcode. So, how will you do it? You can do it using the PHP action hook and do_shortcode() WordPress function. 

Image describing how to show product upsells at Thank You page in WooCommerce

PHP Snippet: WooCommerce Show Product Upsells at Thank You page

add_action( 'woocommerce_thankyou', 'phpsof_upsells_thankyou' );
 
function phpsof_upsells_thankyou() {
   echo '<h2>Buy Some More?</h2>';
   echo do_shortcode( '[products ids="186177,186179,186181"]' );
}

Where do you add this snippet?

So, this is how you can show product upsells at Thank You page. Also, it is easier to activate this function with this code. So, to apply this code, just add this PHP snippet at your child theme function.php file’s bottom. It should be placed before “?>”, if you have it there. Apart from this, CSS goes in your child theme style.css file. Make sure that you are editing these files in a right manner for best results.

Is this snippet still valid?

So, this is how you can learn about show product upsells at Thank You page. I have applied this code on the Storefront theme and WordPress friendly hosting PHP 7.3. Let me know if everything works as expected when you code. Share it further if you find this snippet useful for you and it had saved your time. 

Also Read, How to Create Custom Product Tabs in WooCommerce?

How to Show Product Stock at Cart Page in WooCommerce?

Important links: WooCommerce – https://woocommerce.com/