/**
* @snippet Adding Upsell Products To WooCommerce Thank You Page
* @web wpcues.com
* @compatible WooCommerce 6
*/
add_action( 'woocommerce_thankyou', 'wpc_thankyou_upsell', 5 );
function wpc_thankyou_upsell() {
echo '<h2>You may interested...</h2>';
echo do_shortcode( '[products limit="4" columns="4" orderby="popularity" on_sale="true"]' );
}
Where to add this code?
You can place PHP snippets at the bottom of your theme’s functions.php file. You may need to delete “?>” if you have it there.