Hello, I would like to not showing any product page, I found it confusing for customers... so I wanted that the button "take the course" redirects directly to check out ...
I checked the Skip product & cart option in the miscenalleous section of wplms setting, so the "take the course" button should redirect to the checkout page...
but now in the cart or in some places there is still the link to the products so I used this code in this topic :
https://wplms.io/support/forums/topic/redirect-product-page-to-course-page/
So I use this code in the function.php file of my child theme...
add_action('template_redirect','custom_redirect_to_course_page_from_product_page',1);
function custom_redirect_to_course_page_from_product_page(){
global $post;
if( get_post_type($post->ID) != 'product' || !is_singular('product') ){
return;
}
$courses = get_post_meta($post->ID,'vibe_courses',true);
if( !empty($courses) && is_array($courses) ){
foreach ($courses as $course_id) {
wp_redirect( get_permalink($course_id) );
exit();
}
}else{
wp_redirect( home_url() );
exit();
}
}
but there's a problem now :
When I can't click on "take the course" on the course page, it redirects to the product which... directly redirect to the course !
can I change the link "Take the course" to go directly to the checkout ?
I can see in the URL there's /product/productname/?redirect
so the product goes now back to the course...
Any ideas to help ?? thanks in advance