Commit 55d622a1ca4 for woocommerce
commit 55d622a1ca4e40b5c2a979d08bf4551b309d4cc9
Author: Luigi Teschio <gigitux@gmail.com>
Date: Thu Jul 16 10:25:19 2026 +0200
Fix WooCommerce Analytics detection in custom directories (#66665)
* Fix WooCommerce Analytics custom-directory detection
* Add changelog entry for custom-directory detection
* fix unit test
* remove unit test
diff --git a/packages/php/woocommerce-analytics/changelog/fix-custom-woocommerce-plugin-directory b/packages/php/woocommerce-analytics/changelog/fix-custom-woocommerce-plugin-directory
new file mode 100644
index 00000000000..59502ece337
--- /dev/null
+++ b/packages/php/woocommerce-analytics/changelog/fix-custom-woocommerce-plugin-directory
@@ -0,0 +1,4 @@
+Significance: patch
+Type: fixed
+
+Recognize active WooCommerce installations in custom plugin directories.
diff --git a/packages/php/woocommerce-analytics/src/class-woocommerce-analytics.php b/packages/php/woocommerce-analytics/src/class-woocommerce-analytics.php
index b105daa8d87..677eeb99390 100644
--- a/packages/php/woocommerce-analytics/src/class-woocommerce-analytics.php
+++ b/packages/php/woocommerce-analytics/src/class-woocommerce-analytics.php
@@ -90,7 +90,7 @@ class Woocommerce_Analytics {
*
* This action is documented in https://docs.woocommerce.com/document/create-a-plugin
*/
- if ( ! is_plugin_active( 'woocommerce/woocommerce.php' ) ) {
+ if ( ! defined( 'WC_PLUGIN_FILE' ) || ! is_plugin_active( plugin_basename( WC_PLUGIN_FILE ) ) ) {
return false;
}
// Ensure the WooCommerce class exists and is a valid version.
diff --git a/packages/php/woocommerce-analytics/tests/php/Woocommerce_Analytics_Test.php b/packages/php/woocommerce-analytics/tests/php/Woocommerce_Analytics_Test.php
index 973d2b27dd6..b7373b3e977 100644
--- a/packages/php/woocommerce-analytics/tests/php/Woocommerce_Analytics_Test.php
+++ b/packages/php/woocommerce-analytics/tests/php/Woocommerce_Analytics_Test.php
@@ -10,6 +10,11 @@ namespace Automattic\Woocommerce_Analytics;
use Automattic\Woocommerce_Analytics;
use WorDBless\BaseTestCase;
+/**
+ * WooCommerce test double.
+ */
+class WooCommerce_Test_Double {}
+
/**
* Tests for the Woocommerce_Analytics class.
*