From 5f4c5bc61a1fe9bce1969bfaeb950707dd499db5 Mon Sep 17 00:00:00 2001 From: Wesley Rosa Date: Tue, 16 Jul 2024 12:22:43 -0300 Subject: [PATCH] Fix fatal errors when subscription classes are not available (#8823) Co-authored-by: Wesley Rosa Co-authored-by: Diego Curbelo Co-authored-by: Francesco --- changelog/fix-fatal-errors-when-subscriptions-are-unavailable | 4 ++++ .../subscriptions/class-wc-payments-subscription-service.php | 4 ++++ 2 files changed, 8 insertions(+) create mode 100644 changelog/fix-fatal-errors-when-subscriptions-are-unavailable diff --git a/changelog/fix-fatal-errors-when-subscriptions-are-unavailable b/changelog/fix-fatal-errors-when-subscriptions-are-unavailable new file mode 100644 index 00000000000..aa457b9b6f0 --- /dev/null +++ b/changelog/fix-fatal-errors-when-subscriptions-are-unavailable @@ -0,0 +1,4 @@ +Significance: patch +Type: fix + +Fixing fatal errors when subscription classes are not available diff --git a/includes/subscriptions/class-wc-payments-subscription-service.php b/includes/subscriptions/class-wc-payments-subscription-service.php index 229bef20ae7..b68bd99cbbe 100644 --- a/includes/subscriptions/class-wc-payments-subscription-service.php +++ b/includes/subscriptions/class-wc-payments-subscription-service.php @@ -1080,6 +1080,10 @@ private function validate_subscription_data( $subscription_data ) { * @return bool True if store has active WCPay subscriptions, otherwise false. */ public static function store_has_active_wcpay_subscriptions() { + if ( ! function_exists( 'wcs_get_subscriptions' ) ) { + return false; + } + $active_wcpay_subscriptions = wcs_get_subscriptions( [ 'subscriptions_per_page' => 1,