Skip to content

Instantly share code, notes, and snippets.

@AladinDridi
Last active May 15, 2018 10:11
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 AladinDridi/442db23c731fae9d6dfb54e10f3e6014 to your computer and use it in GitHub Desktop.
Save AladinDridi/442db23c731fae9d6dfb54e10f3e6014 to your computer and use it in GitHub Desktop.
add_action( 'woocommerce_thankyou', 'ad_redirectcustom');
function ad_redirectcustom( $order_id ){
$order = new WC_Order( $order_id );
$items = $order->get_items();
$product_id=223074;//id of your product
$product_id2=223076;// id of your product
$url ='';// url for the redirection after purchase your product
$url2='';
foreach ( $items as $item ) {
if (($order->status!='failed')&&(product_id==$item['product_id'])) {
wp_redirect($url);
exit;
}
else if (($order->status!='failed')&&($product_id2==$item['product_id'])) {
wp_redirect($url2);
exit; //
}
}
}
@AladinDridi
Copy link
Author

i 'll create youtube tutorial explain this

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