Woocommerce – Redirect Product ID to Custom Thank You Page

function wcs_redirect_product_based ( $order_id ){
	$order = wc_get_order( $order_id );

	foreach( $order->get_items() as $item ) {
		$_product = wc_get_product( $item['product_id'] );
		// Add whatever product id you want below here
		if ( $item['product_id'] == 70 ) {
			// change below to the URL that you want to send your customer to
add_action( 'woocommerce_thankyou', 'wcs_redirect_product_based' );

Added to functions.php – updated the Product ID where specified in the comments and save.

Sourced here.

Leave a Reply

katherine as a flat graphic icon

About Me

I’m an African / Ojibwe First Nations Web Developer living in Winnipeg, Manitoba.

Visit the Tips and Blog to see what I’m working on.