One of the most important WooCommerce pages, conversion-wise, is the Thank You page. That’s your chance to offer something special to a user that has just turned into a customer and is therefore more likely to purchase again.

We’ve seen how to include a whole WordPress page inside the Thank You page, how to redirect customers to a different Thank You page URL, how to display a custom social media share box on the Thank You page, but in this article I want to expand a little more on the topic and show a list of purchasable products via a shortcode.

The thing is that the Thank You page “does not exist” inside the WordPress pages, so you can’t just add a shortcode in a page. We must do that via a PHP action hook and the do_shortcode() WordPress function. Enjoy!

PHP Snippet: Display Products @ WooCommerce Thank You Page

 * @snippet       Display Product Shortcode @ WC Thank You
 * @how-to        Get FREE
 * @author        Rodolfo Melogli
 * @testedwith    WooCommerce 3.8
 * @donate $9

add_action( 'woocommerce_thankyou', 'bbloomer_upsells_thankyou' );

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


Leave a Reply