Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Paste it on yourtheme/woocommerce/checkout/thankyou.php
- foreach ( $order->get_items() as $item_id => $item ) { // Get All Order Items
- $product_id = $item['product_id']; // Ordered Product ID
- $product_courses = get_post_meta( $product_id, '_related_course'); // Orderd Product Course
- if( $product_courses && is_array($product_courses)) { // If it's product and have data
- foreach ($product_courses as $product_course) { // Get Each Course ID
- $course_link = get_post_permalink($product_course[0]); // First Course Permalink
- wp_redirect($course_link); // Redirect to course homepage
- exit(); // Stop execute script
- // echo "<pre>";
- // print_r($course_link);
- // echo "</pre>";
- }
- }
- }
Add Comment
Please, Sign In to add comment