Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix WooCommerce deactivation handler #952

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions classes/WooCommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public function __construct() {
* @since 1.7.8
*/
$woocommerce_path = dirname( dirname( __DIR__ ) ) . DIRECTORY_SEPARATOR . 'woocommerce' . DIRECTORY_SEPARATOR . 'woocommerce.php';
register_deactivation_hook( $woocommerce_path, array( $this, 'disable_tutor_monetization' ) );
register_deactivation_hook( $woocommerce_path, array( $this, 'woocommerce_deactivation_handler' ) );
/**
* Redirect student on enrolled courses after course
* Enrollment complete
Expand Down Expand Up @@ -664,15 +664,25 @@ public function course_placing_order_from_customer( $item_id, $item, $order_id )
}

/**
* Disable course monetization on woocommerce deactivation
* Handle disabling WooCommerce monetization on WooCommerce plugin deactivation
*
* @since 1.7.8
*
* @return void
*/
public function disable_tutor_monetization() {
tutor_utils()->update_option( 'monetize_by', 'free' );
update_option( 'tutor_show_woocommerce_notice', true );
public function woocommerce_deactivation_handler() {
if ( tutor_utils()->get_option( 'monetize_by' ) === 'wc' ) {
tutor_utils()->update_option( 'monetize_by', 'free' );
/**
* Show a reminder to re-enable Tutor monetization to
* monetize courses after re-activating WooCommerce:
*
* Possible follow-up fix: Only show a notice when
* WooCommerce was re-activated after this forced
* disabling of WooCommerce monetisation took place:
*/
update_option( 'tutor_show_woocommerce_notice', true );
}
}

/**
Expand Down