Need help with CoursePress Pro.

I am trying to get CoursePress up and running and am having some issues. I've read through all the documentation, but I still have questions that aren't answered here. On the checkout page, when they have registered for the course, I'd like to include a button to take them directly to start the course they registered for. Essentially, you click 'enroll in the course', and then you go to check out. You put in all your billing details, and then the final page is a receipt of your transaction.
It's on that final transaction receipt page that I want a button to go ahead and go straight to the course so a student doesn't have to go wait on an email to come through to get a link for it. But the button has to be dynamic, pending whatever class they just enrolled in. Please help.

  • Panos
    • SLS

    Hi Laura ,

    This is an interesting request :slight_smile:

    There's no option for this though, we can try with a custom snippet. As this requires some custom coding and not sure how close to your needs we can get, we'll need some time to check it out. I have tasked it and will get back to with an update.

    I logged in to yoursite.com/gpi-dev and noticed you are using WooCommerce for payments. Could you confirm tat you are indeed using WooCommerce, as I am not sure that I had access to the correct site?

    Kind regards!

  • Laura
    • WPMU DEV Initiate

    Hi,

    Thanks! I think we figured out a workaround. It's another click, which isn't ideal, but we could create a button to take them to their dashboard first, and from there they can click on the course they just registered for.

    We are, in fact, using woo commerce. However, last night I spun up a separate instance of wordpress so we could use the CoursePro theme without affecting the rest of our site. It's at http://www.geoinsights.com/courses/wp-admin. I can also enable support access for that site.

  • Panos
    • SLS

    Hi Laura !

    Thanks for your reply!

    I see you mentioned that you have a workaround already, I'll just follow up here with my thoughts if you don't mind :slight_smile:

    The appropriate place for that link, would be in the page after WC payment is completed:
    site.com//checkout/order-received/...

    In that page CoursePress already prints a thank you message. In that thank you message, if the order is paid, CoursePress adds another message:

    You can find the course in your Dashboard

    with a link to the dashboard.

    We can either replace that last message or add links after that. Just want to clear something here first. If it is not paid (eg if gateway delays or paid with Bank transfer), when user goes to course page, he will be asked to pay for it again. So I would suggest to show your link/button only if order is paid.

    Here is a sample snippet that should add link(s) to course(s) bought in current order:

    // Removes the default CP action
    add_action( 'woocommerce_order_details_after_order_table', function(){
    	remove_action( 'woocommerce_order_details_after_order_table', array( 'CoursePress_Helper_Integration_WooCommerce', 'show_course_message_woocommerce_order_details_after_order_table' ) );
    }, 1 );
    
    add_action( 'woocommerce_order_details_after_order_table', function( $order ){
    
    	$order_details		 = new WC_Order( $order->id );
    	$order_items		 = $order_details->get_items();
    	$purchased_course	 = false;
    	$courses_links 		 = array();
    
    	foreach ( $order_items as $order_item ) {
    		$course_id = wp_get_post_parent_id( $order_item['product_id'] );
    		if ( $course_id && get_post_type( $course_id ) == 'course' ) {
    			$course = CoursePress_Data_Course::get_course( $course_id );
    			$courses_links[] = "<a href=\"{$course->permalink}\">{$course->post_title}</a>";
    			$purchased_course = true;
    		}
    	}
    
    	if ( ! $purchased_course ) {
    		return;
    	}
    
    	printf( '<h2 class="cp_woo_header">%s</h2>', esc_html__( 'Course', 'coursepress' ) );
    	printf( '<p class="cp_woo_thanks">%s</p>', esc_html__( 'Thank you for signing up for the course. We hope you enjoy your experience.', 'coursepress' ) );
    
    	// Messages to be printed only if order is completed:
    	if ( is_user_logged_in() && 'wc-completed' == $order->post_status ) {
    
    		echo '<p class="cp_woo_dashboard_link">';
    
    		// Thsi is the default CoursePress message. You can keep it or remove it
    		printf(
    			__( 'You can find the course in your <a href="%s">Dashboard</a>', 'coursepress' ),
    			( method_exists( 'CoursePress_Core', 'get_slug' ) ) ? CoursePress_Core::get_slug( 'student_dashboard', true ) : ''
    		);
    
    		//This is the custom links, you can modify the message as you wish
    		if ( ! empty( $courses_links ) ) {
    			$label = "You can visit your course here:";
    
    			if ( 1 < count( $courses_links ) ){
    				$label = "You can visit your courses here:";
    			}
    
    			echo "<div>";
    				echo "<strong>{$label}</strong>";
    
    				foreach ( $courses_links as $course_link ) {
    					echo "<div>{$course_link}</div>";
    				}
    
    			echo "</div>";
    		}
    
    		echo '</p><hr />';
    	}	
    
    } );

    You can add that snippet in a mu-plugin, or in your child theme's functions.php. If you are not familiar with mu-plugins you can read about them here :
    https://premium.wpmudev.org/manuals/wpmu-manual-2/using-mu-plugins/

    Hope this helps!

    Kind regards!

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.