• Hi! I’m using Tutor LMS to host the courses, Woocommerce for the shop and PMPro to give membership levels together with the courses.

    Until two days ago, this was working beautifully.

    Since yesterday, I’m finding that the students are not enrolled in Tutor LMS. The order is placed, the membership is given, but the enrollment is not active.

    I have the autocomplete option checked in Tutor, as it was before when all was working well.

    I tried in a clean installation also to avoid conflicts with other plugins.

    The only plugins active are Woocommerce, PMPro, PMPro Wooc Add on and Tutor LMS.

    • When Woocommerce and PMPro (+addon) are active only, the memberships work well.
    • When Woocommerce and Tutor LMS are active only, the enrollments are working well.
    • When Woocommerce, PMPro (+addon) and Tutor LMS are active, the enrollments are not working.

    Could you please help find the issue?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter guezs

    (@guezs)

    I see that there’s a conflict between both plugins: when the order autocompletes in PMPro due to it’s needed for the membership, Tutor LMS avoid the autocompletion.

    And, when Tutor LMS autocompletes, PMPro doesn’t.

    Each plugin is only enrolling when the order completion is done by itself, not when the order is already completed.

    • This reply was modified 2 years, 1 month ago by guezs.
    Thread Starter guezs

    (@guezs)

    I’m trying to narrow what’s happening tracing the code and I can see the following:

    1. When the order is only marked as For Tutor, enrolled_courses_status_change is called once with status processing and all is great
    2. When the order is marked as For Tutor and also PMPro is marked as autocomplete, enrolled_courses_status_change is called twice
    3. The first one with the status complete, so it generates the user_id and course_id at in the complete status evaluation at the end of the function
    4. And the second one with status processing (why?) while order_status is still complete, so should_order_auto_complete returns false and user_id and course_id are unset, so no enrollment at the end

    This is a weird behaviour… I checked that both plugins are being called and both do their work independently of the autocomplete, so I don’t know why this function is called twice at this point.

    Thanks

    Thread Starter guezs

    (@guezs)

    If I could just have checked the Autocomplete from Tutor LMS and uncheck the Autocomplete from PMPro for those products, it would work, but Tutor LMS modifies the order table directly in mark_order_complete to set it to complete instead of calling $order->update_status( ‘completed’ and this might be the reason why the other plugin is not being called on order completion.

    Thread Starter guezs

    (@guezs)

    I changed the code of mark_order_complete in my test site to:

    	public static function mark_order_complete( int $order_id ): bool {
    		if ( is_admin() ) {
    			return false;
    		}
    
    		$order = wc_get_order( $order_id );
    		return $order->update_status( 'completed', esc_html__( 'Autocomplete via Tutor LMS.', 'tutor' ) );
    	}

    and it worked with Tutor LMS autocomplete checked and PMPro autocomplete unchecked.

    Please consider to review this functionality for a new version.

    There are still two calls to the function that I think need to be reviewed, as the contrary should work either: checking autocomplete in PMPro and unchecking in Tutor LMS. If the order is autocompleted, both plugins should work. PMPro does that when the completion is done by the standard calling, so I think this is more in Tutor LMS side.

    As this is the code of the plugin, I wonder how could I turn this into a snippet in the meantime. If you could suggest anything I would appreciate it.

    Thank you

    Thread Starter guezs

    (@guezs)

    I found a workaround by unchecking both autocomplete options in tutor and in pmpro and adding a code in functions.php calling the filter for woocommerce_order_payment_status_changed (to ensure that the order_status_changed for processing is already finished) and evaluating if the order is processing + is from tutor or from pmpro to call $order->update_status( ‘completed’, ‘___’, ‘___’) myself

    Anything inside order_status_changed completing the order while it’s still doing actions for the status processing causes errors, so waiting for this to complete is a better option.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Enrolling not working when having Wooc, PMPro and Tutor LMS working toget’ is closed to new replies.