Skip to content

Instantly share code, notes, and snippets.

@rashmimalpande
Last active June 19, 2022 13:47
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rashmimalpande/2ac56734e9ca9ec767074a9a0a57a02f to your computer and use it in GitHub Desktop.
Save rashmimalpande/2ac56734e9ca9ec767074a9a0a57a02f to your computer and use it in GitHub Desktop.
<?php
add_action( 'woocommerce_thankyou', 'redirect_product_based', 1 );
function redirect_product_based ( $order_id ){
$order = wc_get_order( $order_id );
foreach( $order->get_items() as $item ) {
// Add whatever product id you want below here
if ( $item['product_id'] == 643 ) {
// change below to the URL that you want to send your customer to
wp_redirect( 'http://yoururl.com/custom-thank-you/' );
}
}
}
?>
@ZBytes0
Copy link

ZBytes0 commented Jun 19, 2022

Hi i need this for multipe products please

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment