diff --git a/class-wc-calypso-bridge.php b/class-wc-calypso-bridge.php index a78540a1..b61df724 100644 --- a/class-wc-calypso-bridge.php +++ b/class-wc-calypso-bridge.php @@ -75,6 +75,7 @@ function_exists( 'WC' ) && */ public function __construct() { add_action( 'muplugins_loaded', array( $this, 'deactivate_duplicate_tiktok' ), PHP_INT_MAX ); + add_action( 'muplugins_loaded', array( $this, 'deactivate_wc_services_if_woo_shipping_or_woo_tax_is_active_on_ecomm_plans'), PHP_INT_MAX ); add_action( 'plugins_loaded', array( $this, 'initialize' ), 0 ); add_action( 'plugins_loaded', array( $this, 'load_translation' ) ); } @@ -96,6 +97,32 @@ public function deactivate_duplicate_tiktok() { } } + /** + * Deactivate WooCommerce Services if either Woo Shipping or Woo Tax is active on an ecommerce-related plan. + * + * This applies to WPCOM and Woo Express, including trial plans. + * + * @since x.x.x + * @link https://github.com/Automattic/wc-calypso-bridge/pull/1458 + * + * @return void + */ + public function deactivate_wc_services_if_woo_shipping_or_woo_tax_is_active_on_ecomm_plans() { + if ( ! wc_calypso_bridge_has_ecommerce_features() ) { + return; + } + + $active_plugins = (array) get_option( 'active_plugins', array() ); + $shipping_key = array_keys( $active_plugins, 'woocommerce-shipping/woocommerce-shipping.php' ); + $tax_key = array_keys( $active_plugins, 'woocommerce-tax/woocommerce-tax.php' ); + $services_key = array_keys( $active_plugins, 'woocommerce-services/woocommerce-services.php' ); + + if ( ( ! empty( $shipping_key ) || ! empty( $tax_key ) ) && ! empty( $services_key ) ) { + unset( $active_plugins[ $services_key[0] ] ); + update_option( 'active_plugins', $active_plugins ); + } + } + public function initialize() { if ( ! $this->is_woocommerce_valid() ) { return; diff --git a/readme.txt b/readme.txt index 8b8a3243..c88bb142 100644 --- a/readme.txt +++ b/readme.txt @@ -26,6 +26,7 @@ This section describes how to install the plugin and get it working. * Fix the duplicate My Home menu in Ecommerce Admin Menu = Unreleased = +* Deactivate WooCommerce Services if either Woo Shipping or Woo Tax is active on an ecommerce-related plan (on WPCOM and Woo Express, including trial plans) #1458 = 2.3.12 = * Update DataSourcePoller import since after refactor in core #1450