Skip to content

Instantly share code, notes, and snippets.

@SiR-DanieL
Created August 1, 2016 15:54
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save SiR-DanieL/94cda62d2e7a622530179d0f4cd7b08c to your computer and use it in GitHub Desktop.
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
wp_redirect('http://www.yoururl.com/your-thank-you-page');
}
}
}
add_action( 'woocommerce_thankyou', 'wcs_redirect_product_based' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment