Last active
May 15, 2018 10:11
-
-
Save AladinDridi/442db23c731fae9d6dfb54e10f3e6014 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; // | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
i 'll create youtube tutorial explain this