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 businessbloomer.com/woocommerce-customization
* @author Rodolfo Melogli, Business Bloomer
* @testedwith WooCommerce 7
* @community https://businessbloomer.com/club/
*/
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"]' );
}
Hi Rodolfo,
How could we add/change the product id’s from within an admin panel? Is this possible?
Raj
Hi Raj, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!