Shortcode to display “Enrolled Courses”
-
Hi there!
Is there any way to display the enrolled courses in another page? I’m trying to merge WooCommerce My Account page and “Enrolled Courses” tab.
Thank you!
-
Hello there,
There is no shortcake to do this. You can find the enrolled course page code from tutor/templates/dashboard.php page.
Kind Regards.
The means we can create our own custom shortcode right?
Hello @ralphico
yes please you can create your own shortcode.
If you created the code, can you please share it? I need to show the courses with access in my woocommerce account in downloads
Add this code to your child-theme function.php file & use this shortcode to show enrolled course [enrolled-course]
/** * Enrolled Course Shortcode */ function tutor_enrolled_course_register_shortcodes() { add_shortcode( 'enrolled-course', 'shortcode_tutor_enrolled_course' ); } add_action( 'init', 'tutor_enrolled_course_register_shortcodes' ); /** * Shortcode Callback */ function shortcode_tutor_enrolled_course( $atts ) { ?> <h3><?php _e('Enrolled Courses', 'tutor'); ?></h3> <div class="tutor-dashboard-content-inner"> <?php $my_courses = tutor_utils()->get_enrolled_courses_by_user(get_current_user_id(), array('private', 'publish')); if ($my_courses && $my_courses->have_posts()): while ($my_courses->have_posts()): $my_courses->the_post(); $avg_rating = tutor_utils()->get_course_rating()->rating_avg; $tutor_course_img = get_tutor_course_thumbnail_src(); /** * wp 5.7.1 showing plain permalink for private post * since tutor do not work with plain permalink * url is set to post_type/slug (courses/course-slug) * @since 1.8.10 */ $post = $my_courses->post; $custom_url = home_url($post->post_type.'/'.$post->post_name); ?> <div class="tutor-mycourse-wrap tutor-mycourse-<?php the_ID(); ?>"> <a class="tutor-stretched-link" href="<?php echo esc_url($custom_url);?>"><span class="sr-only"><?php the_title(); ?></span></a> <div class="tutor-mycourse-thumbnail" style="background-image: url(<?php echo esc_url($tutor_course_img); ?>)"></div> <div class="tutor-mycourse-content"> <div class="tutor-mycourse-rating"> <?php tutor_utils()->star_rating_generator($avg_rating); ?> </div> <h3><a href="<?php echo esc_url($custom_url);?>"><?php the_title(); ?></a></h3> <div class="tutor-meta tutor-course-metadata"> <?php $total_lessons = tutor_utils()->get_lesson_count_by_course(); $completed_lessons = tutor_utils()->get_completed_lesson_count_by_course(); ?> <ul> <li> <?php _e('Total Lessons:', 'tutor'); echo "<span>$total_lessons</span>"; ?> </li> <li> <?php _e('Completed Lessons:', 'tutor'); echo "<span>$completed_lessons / $total_lessons</span>"; ?> </li> </ul> </div> <?php tutor_course_completing_progress_bar(); ?> </div> </div> <?php endwhile; wp_reset_postdata(); else: echo "<div class='tutor-mycourse-wrap'><div class='tutor-mycourse-content'>".__('You haven\'t purchased any course', 'tutor')."</div></div>"; endif; ?> </div> <?php }
@largbasket Thanks, brother. You made my day.
Hello @pandyakunalm
You are welcome brother
Would be great if this could be added to the WooCommerce plugin (as an option at least). I also have a working WooCommerce “My Account” page and just need another “Enrolled courses” subpage there.
When I add the shortcode [enrolled-course], I get some “JSON error” message when trying to save the page. I added the code through Code Snippets. Is that correct?
Also the short code seems to be full width and can’t be made less wide somehow …
Dear @gerdneumann
You need to customize the woocommerce My Account page.
Dear @janolan
You can use the shortcode as your wish. You can set the width using custom css. If you use classic editor then you will not face the JSON error.
Hello,
I wonder how to edit
tutor_course_completing_progress_bar();
I want to make it circular instead of straight line on dashboard pages.Dear @shaadakhan
You need to edit this file
/tutor/templates/single/course/enrolled/completing-progress.php
@largbasket Thanks for the reply.
I already achieved this by doing:if($total_lessons != "0" && $completed_lessons != "0"){ $total_l = (int)$total_lessons; $completed_c = (int)$completed_lessons; $percentage = ( $completed_c/$total_l) * 100; $uncompleted = 100 - round($percentage); echo round($percentage) . " Percentage <br>"; echo $uncompleted; }else{ // Do something }
But i want to make it circular on dashboard page in loop.
@shaadakhan You are welcome.
If you want to show it in the loop, you need to modify this file. Because the progress bar is coming from here.
/tutor/templates/single/course/enrolled/completing-progress.php
- The topic ‘Shortcode to display “Enrolled Courses”’ is closed to new replies.