Skip to content

Commit

Permalink
Account for Subscriptions Core library when checking for Subscriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
unfulvio committed Sep 25, 2024
1 parent c561eab commit 86e3200
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
19 changes: 17 additions & 2 deletions woocommerce/class-sv-wc-plugin-compatibility.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
}


Expand Down

0 comments on commit 86e3200

Please sign in to comment.