Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save AladinDridi/522da465af8299b84a20565ee8087246 to your computer and use it in GitHub Desktop.
Save AladinDridi/522da465af8299b84a20565ee8087246 to your computer and use it in GitHub Desktop.
add_action( 'woocommerce_thankyou', 'bbloomer_redirectcustom');
function bbloomer_redirectcustom( $order_id ){
global $current_user;
$order = new WC_Order( $order_id );
$items = $order->get_items();
$product_id=223074;
$product_id2=223076;
foreach ( $items as $item ) {
$url ='';
$url2='';
if (($order->status!='failed')&&($order->payment_method =='other_payment')&&(( user_can( $current_user, "7eme")))&&($product_id==$item['product_id'])) {
wp_redirect($url);
exit;
}
else if (($order->status!='failed')&&($order->payment_method =='other_payment')&&(( user_can( $current_user, "7eme")))&&($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