diff --git a/woocommerce/class-sv-wc-plugin-compatibility.php b/woocommerce/class-sv-wc-plugin-compatibility.php index 14d946090..106cd4d1b 100644 --- a/woocommerce/class-sv-wc-plugin-compatibility.php +++ b/woocommerce/class-sv-wc-plugin-compatibility.php @@ -322,9 +322,24 @@ public static function is_wc_subscriptions_version_lt( $version ) { * * @return string|null WooCommerce Subscriptions version number or null if not found */ - protected static function get_wc_subscriptions_version() { + protected static function get_wc_subscriptions_version() : ?string { - return class_exists( 'WC_Subscriptions' ) && ! empty( \WC_Subscriptions::$version ) ? \WC_Subscriptions::$version : null; + if ( class_exists( 'WC_Subscriptions' ) && ! empty( \WC_Subscriptions::$version ) ) { + return \WC_Subscriptions::$version; + } + + if ( class_exists( 'WC_Subscriptions_Core_Plugin' ) ) { + if ( is_callable( [ \WC_Subscriptions_Core_Plugin::class, 'instance' ] ) ) { + + $instance = \WC_Subscriptions_Core_Plugin::instance(); + + if ( is_object( $instance ) && method_exists( $instance, 'get_library_version' ) ) { + return $instance->get_library_version(); + } + } + } + + return null; } diff --git a/woocommerce/payment-gateway/class-sv-wc-payment-gateway-plugin.php b/woocommerce/payment-gateway/class-sv-wc-payment-gateway-plugin.php index 84fa09aa8..080eab883 100644 --- a/woocommerce/payment-gateway/class-sv-wc-payment-gateway-plugin.php +++ b/woocommerce/payment-gateway/class-sv-wc-payment-gateway-plugin.php @@ -1364,13 +1364,13 @@ public function get_accepted_currencies() { * * @return bool true if the WooCommerce Subscriptions plugin is active, false if not active */ - public function is_subscriptions_active() { + public function is_subscriptions_active() : bool { if ( is_bool( $this->subscriptions_active ) ) { return $this->subscriptions_active; } - return $this->subscriptions_active = $this->is_plugin_active( 'woocommerce-subscriptions.php' ); + return $this->subscriptions_active = class_exists( 'WC_Subscriptions_Core_Plugin' ) || $this->is_plugin_active( 'woocommerce-subscriptions.php' ); }