Automattic / sensei

Sensei LMS - Online Courses, Quizzes, & Learning
https://senseilms.com
GNU General Public License v2.0
539 stars 198 forks source link

WooCommerce Paid Courses: You are already taking all the courses associated with this product. #4346

Closed joashrajin closed 2 years ago

joashrajin commented 2 years ago

When installing WooCommerce Paid Courses v3.13.3.2.6.0 on my fresh WC Site, I keep getting an error 'You are already taking all the courses associated with this product.' when trying to add a product to my cart. This did not occur on my sites using 3.13.1.2.5.0, but all sites updated to 3.13.3.2.6.0 are doing this.

Steps to Reproduce

  1. Install the latest version of WooCommerce Paid Courses to your WC Site
  2. Create a simple product, open up the product page and try to add that product to your cart
  3. The WooCommerce Notice should then say: 'You are already taking all the courses associated with this product.' and the product won't be added to your cart
  4. Disabling WC Paid Courses or downgrading to 3.13.1.2.5.0 fixes the problem.

What I Expected

I expected to be able to add simple/variable products to my cart and that the site would function normally

What Happened Instead

I got an error message related to courses (which should not be linked to my simple product)

PHP / WordPress / Sensei LMS version

PHP: 8.0.11 WordPress: 5.8.1 Sensei LMS Version: 3.13.3 WooCommerce Paid Courses Version: 2.6.0

Browser / OS version

Chrome v94.0.4606.81 MacOS 11.6

Screenshot / Video

image

https://user-images.githubusercontent.com/16253818/137153333-2acb706c-7aa6-4075-98e0-2ed09cb316aa.mp4

robertstaddon commented 2 years ago

This also just started happening on my site after upgrading to WooCommerce Paid Courses v3.13.3.2.6.0

cena commented 2 years ago

4375258-zen

gikaragia commented 2 years ago

Hello @robertstaddon and @joashrajin,

can you try using the below snippet until we get a hotfix ready?

function remove_cart_notice() {
    remove_action( 'woocommerce_add_to_cart', [ 'Sensei_WC', 'do_not_add_course_to_cart_if_user_taking_course' ], 10 );
}
add_action( 'woocommerce_add_to_cart', 'remove_cart_notice', 9 );

Please mind that this will remove all Sensei-related notices in the cart but at least will allow customers add the product.

robertstaddon commented 2 years ago

Thank you for this! I have rolled all my Sensei sites back to v3.13.2.2.5.0 so I'll just hold on updating until the hotfix is released.

joashrajin commented 2 years ago

@gkaragia Thanks! I can confirm that the snippet fixes the problem :)

renatho commented 2 years ago

Hey folks! Thank you for reporting this! 👍

We just released a fix for WooCommerce Paid Courses. Any other related issues, feel free to answer here. 😉