Skip to content

Commit

Permalink
Deactivate WooCommerce Services if either Woo Shipping or Woo Tax is …
Browse files Browse the repository at this point in the history
…active (#1458)

Co-authored-by: André Kallehauge <[email protected]>
  • Loading branch information
waclawjacek and kallehauge authored Apr 19, 2024
1 parent a7707fd commit 4a6fe76
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
27 changes: 27 additions & 0 deletions class-wc-calypso-bridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' ) );
}
Expand All @@ -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;
Expand Down
1 change: 1 addition & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4a6fe76

Please sign in to comment.