Course not added to user after payment
-
on the page https://wewnatrz-relacji.pl/kursy/
it is happening to about 20% of cases that despite purchasing the course it is not added to the users dashboard.
Than I give the user a discount (100%) code to purchase again and then it works. It is added to users dashboard.What can be the reason.
-
I have exactly the same problem.
In my case the issue is 100% cases when user is registered during checkout. I the user buys the course when he already has an account and is logged in, it will enroll more often than not.I have exactly the same problem.
We are currently conducting a service test by integrating tutorLMS pro 2.5 with WooCommerce.Upon completing an order using my student account, I may encounter an issue where I am unable to view course details in the Student Dashboard under “Order History” or the list of registered courses.
This issue persists regardless of the payment method selected and remains unresolved even after disabling other plugins.
However, you can still access and check this information under “Admin > WooCommerce > Orders.”
** Debug.log
[11-Jan-2024 03:54:39 UTC] string(15) “not tutor order”[11-Jan-2024 03:55:00 UTC] PHP Notice: Function ID was called incorrectly. Order properties should not be accessed directly. Backtrace: do_action(‘woocommerce_page_wc-orders’), WP_Hook->do_action, WP_Hook->apply_filters, Automattic\WooCommerce\Internal\Admin\Orders\PageController->output, Automattic\WooCommerce\Internal\Admin\Orders\Edit->display, Automattic\WooCommerce\Internal\Admin\Orders\Edit->render_meta_boxes, do_meta_boxes, Cosmosfarm_Members_Meta_Box->render_page_restriction, WC_Abstract_Legacy_Order->__get, wc_doing_it_wrong For more information See Debugging WordPress. (This message was added in version 3.0.) in /home/customer/www/valuepage.kr/public_html/tipstagram/wp-includes/functions.php on line 6031
We kindly request assistance in resolving this matter.
Thank you.
- This reply was modified 10 months, 2 weeks ago by valuepage.
@valuepage
I think your issue is a bit different. In our case, the issue is that the Order is visible in Tutor, but the student is not enrolled correctly.
However, I also had similar problem as you (Woocommerce was showing order and Tutor not). For me the issue was fixed when I changed i WooCommerce Settings >> Advanced >> Featured following settings:
- WordPress posts storage (legacy) as checked
- High-performance order storage as unchecked
- Enable compatibity mode as checked
- Enable WooCommerce analitics as checked
Here grab a screenshot: https://prnt.sc/pMh921nc5M7g
Thank you so much Stepello.
I had a hard time resolving this issue for several days, but thanks to you, I solved it in one go.
I hope your problem gets resolved soon too.
Since Tutor team is not very supportive with this matter, I decided to toggle this issue on my own and actually succeeded ??
The issue took place in the first place because when customer who never made order in our shop (therefore no account) started to fill in checkout fields Woocommerce created a draft order. Then tutor based on that order would create post (post type: tutor_enrolled) in wp-posts table. But since at this stage there is no customer_id it would set post_author to 0. And you need to know that the enrollment in Tutor is dependent on this post (it needs to have type: tutor_enrolled, contain customer_id as post_author and have status completed, and reference correct course).
Since in my case customer account is created when customer presses “Order” on checkout, we have the customer_id at the point when order changes status. From there the fix is to modify 2 tutor php files:
- public_html/kursy/wp-content/plugins/tutor/classes/WooCommerce.php
- public_html/kursy/wp-content/plugins/tutor/classes/Utils.php
Please note the location of those files might be different in your case, but it should not be an issue for you to find it ??
In Woocommerce.php we modify function: enrolled_courses_status_change to this (change in bold):
/** * Take enrolled course action based on order status change * * Order auto complete * * @param int $order_id wc order id. * @param string $status_from from status. * @param string $status_to to status. * * @return void */ public function enrolled_courses_status_change( $order_id, $status_from, $status_to ) { if ( ! tutor_utils()->is_tutor_order( $order_id ) ) { return; } $enrolled_ids_with_course = tutor_utils()->get_course_enrolled_ids_by_order_id( $order_id ); if ( $enrolled_ids_with_course ) { $enrolled_ids = wp_list_pluck( $enrolled_ids_with_course, 'enrolled_id' ); if ( is_array( $enrolled_ids ) && count( $enrolled_ids ) ) { foreach ( $enrolled_ids as $enrolled_id ) { /** * If order status is processing and payment is not cash on * delivery then mark enrollment as completed. * * Note: Order status processing simply mean customer have done * payment. * * @since v2.0.5 */ if ( self::should_order_auto_complete( $order_id ) ) { // Mark enrollment as completed. tutor_utils()->course_enrol_status_change( $enrolled_id, 'completed', $order_id ); // Mark WC order as completed. self::mark_order_complete( $order_id ); } else { tutor_utils()->course_enrol_status_change( $enrolled_id, $status_to, $order_id ); } // Invoke enrolled hook. if ( 'completed' === $status_to ) { $user_id = get_post_field( 'post_author', $enrolled_id ); $course_id = get_post_field( 'post_parent', $enrolled_id ); do_action( 'tutor_after_enrolled', $course_id, $user_id, $enrolled_id ); } } } } }
Then in the Utils.php the change is much heavier so just compare it with what you already have. Function that needs modification is: course_enrol_status_change
/** * Enrol Status change * * @since 1.6.1 * * @param bool $enrol_id enrol id. * @param string $new_status new status. * @param int $order_id order id * * @return mixed */ public function course_enrol_status_change( $enrol_id = false, $new_status = '', $order_id = 0 ) { if ( ! $enrol_id ) { return; } global $wpdb; // Get customer ID from the order $order = wc_get_order( $order_id ); if ( $order && is_a( $order, 'WC_Order' ) ) { $customer_id = $order->get_customer_id(); if ( $customer_id ) { // Trigger action before the status change do_action( 'tutor/course/enrol_status_change/before', $enrol_id, $new_status); // Update post status, post author, and post modified time $result = $wpdb->update( $wpdb->posts, array( 'post_status' => $new_status, 'post_author' => $customer_id, ), array( 'ID' => $enrol_id ) ); // Trigger action after the status change do_action( 'tutor/course/enrol_status_change/after', $enrol_id, $new_status); // Check and log the result if ( $result === false ) { error_log( "Failed to update post_author for enrol_id: $enrol_id" ); } } } }
And that would be all. Remember that this will be overridden when you update Tutor!!!
I tested it with Paypal payment (order closed automatically) and bank transfer (manually close order) in both cases it worked correctly.
If someone has an idea how to implement this in functions.php of child theme, please let me know!
I had some messages exchanged with Tutor team regarding this issue, and they were stating that enrollment issue is due to 100% coupon (I used that for testing) or price set to 0. This is not true! It’s because this entry to wp-posts table when woocommerce saves draft order. I’m not that used to github repos and don’t know how suggest it there, so please Tutor team fix it for next release, and I don’t mind you using this code ??
Dear @luxworx, @stepello, @valuepage
This problem was appeared in Tutor LMS 2.5.0 version but we have fixed it in the latest version of Tutor LMS please update to the 2.6.0 version. And perform the course purchase operation again the functionality will work fine.
I am using the 2.6.0 version, and it still did not work correctly for me.
Are there any additional actions required when updating to 2.6.0 from previous version for it to work correctly?Dear @stepello
I will request you to send an email in support at themeum dot com and share this conversation link in the email.
We need to troubleshoot the site and check deeper to find out the problem.Unfortunately, I have exactly the same problem.
The customer buys the course and is redirected to his dashboard after payment. However, the course is not displayed there.
How can I solve this quickly?I also have the exact same problem. Purchase is in the Tutor history, but the student isn’t enrolled.
I installed the plug-in a few days ago and it’s the last version (2.6.0). I have this problem with all kind of payments.
It’s a major issue because there’s no way I can ask people to pay and they won’t get their course. That’s the last step before I can share my website. If I can’t find a solution soon, I’ll look for another LMS plug-in.
Does aanyone know a good alternative?
Dear @alexia3089, @glbimmer
Please send an email to support at themeum dot com. We need to troubleshoot your site and check deeper to find out the problem.I already sent a message 3 days ago but didn’t get any answer yet. I finally changed the code following what @stepello posted earlier in this post and now it works fine. I just hope the issue won’t come back when there’s an update.
I have the same issue. Course not added to user after payment. Version 2.6.1 Please fix it as this is causing us to lose students and revenue.
I’m already thinking about another LMS plug-in… It is unbelievable.
Dear @alanbee
Please change your WooCommerce Settings according to the screenshots below. Also must enable the Automatically Complete WooCommerce Orders option from the Tutor LMS settings.
It is working! Thank you. I had it on WordPress posts storage (legacy) before and from some reason that changed to High-performance order storage (recommended). I have changed it back and now it works, will fix this to work with High-performance order storage (recommended) as well soon?
Thank you very much for your help!
- You must be logged in to reply to this topic.