Support » Plugin: Tutor LMS - eLearning and online course solution » How to avoid re-buying of the same course by one user?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support munayam


    Hello @tigzik,

    Do you have new user default role set as subscriber from WordPress settings > general?

    A logged in student can’t repurchase the same course but a guest user can I noticed but in his/her Tutor dashboard purchase history he/she won’t see the same course twice. It does create a new woocommerce order so the workaround is to disable guest user. Even if you don’t disable guest user I don’t see the same course appearing twice on a student’s frontend dashboard. Remember to select simple, virtual and for Tutor under the woocommerce product data when you create a product.

    Thread Starter tigzik


    Hi @munayam and thank you for your answer.

    I do have set my products as ‘virtual’ and ‘Tutor’. I didn’t have the default role set as subscriber, so I did as per your advice. The problem remains though.

    1) As a newcomer without account, I add a course either from the course_page or course list to the cart.
    2) On the WooCommerce checkout page I choose a login and password for new account and finish the order with selected payment option.
    3) Order is completed. I can see the course in my Tutor menu and also I can see the enrollment for this user in the Tutor Pro backend.

    From here the issue starts..

    4) I log out. As a visitor I can add the same course to the cart now.
    5) On the WooCommerce checkout page I choose to log in under my existing account. The course remains in the cart and WC allows me to proceed the order.
    6) When the order completes:
    – I can see the course only once on enrolled_courses page in Tutor. That’s ok.
    I can see two orders on the purchase_history page in Tutor. That’s ok from the functionality perspective but I was able to buy the same course twice which is not ok at all.
    The user has two enrollments for the same course as I can see in the Tutor Pro backend. That’s not ok. I didn’t check how it deals with the progress of the course when they are more than one enrollment but I guess it can’t be good / wanted behaviour.

    I can’t prohibit visitors to see courses because I want them to see its info/desc and some preview lessons. Customers decide whether to purchase the course or not based on that.

    I can’t prohibit visitors to add courses to the cart without an account because this is the typical behaviour of our customers. Forcing them to create an account first before being able to add a course to the cart is not a good idea. It won’t be seamless and straightforward experience.

    Thread Starter tigzik


    Thanks to the community here I have a walkaround solution that works well. It checks if a product was bought by the same user (email or id) in the past and won’t allow to proceed onto the checkout page with this product in the cart.

    function action_woocommerce_check_cart_items() {
        // Retrieve the current user object
        $current_user = wp_get_current_user();
        // Initialize
        $flag = false;
        // Loop through cart items
        foreach( WC()->cart->get_cart() as $cart_item ) {
            // Check for variantions
            $product_id = $cart_item['variation_id'] > 0 ? $cart_item['variation_id'] : $cart_item['product_id'];
            // Checks if a user (by email or ID or both) has bought an item
            if ( wc_customer_bought_product( $current_user->user_email, $current_user->ID, $product_id ) ) {
                // Flag becomes true
                $flag = true;
                // Break loop
        // True
        if ( $flag ) {
            // Clear all other notices          
            // Avoid checkout display an error notice
            wc_add_notice( __( 'My custom error message', 'woocommerce' ), 'error' );
            // Optional: remove proceed to checkout button
            remove_action( 'woocommerce_proceed_to_checkout', 'woocommerce_button_proceed_to_checkout', 20 );   
    add_action( 'woocommerce_check_cart_items' , 'action_woocommerce_check_cart_items', 10, 0 );

    I believe there will be a solution / fix for this in Tutor itself in the future.

    Plugin Support munayam


    Hello @tigzik,

    Thanks for sharing your findings.

    I’m suspecting you’ve disabled Tutor Native Login from Tutor settings > general and enabled a custom registration page to register users which is why you might be seeing double purchase from Tutor dashboard/purchase-history.

    Try using the default student registration page and select simple and virtual product under the woo product data.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to avoid re-buying of the same course by one user?’ is closed to new replies.