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; // | |
} | |
} | |
} |
hi thank u for asking me ;) $prudct_id2 , is the id of your product that u want him redirect to the pages , for example $url='www.google.fr' , then out in the code
if (($order->status!='failed')&&(product_id==$item['product_id'])) {
wp_redirect($url);
exit;
}
so when user purchase that product he will redirect to the url , in my example $url='www.google.fr'
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
BTw I dont understand: What is this? == $product_id2=223076;// must be change by id of you product
foreach ( $items as $item ) {
And what is this for?=== $url2='';