Skip to content

Commit 661cf26

Browse files
wjrosadaledupreez
andcommitted
Removing the detached subscriptions notice feature (#4320)
* Removing the detached subscriptions notice feature * Changelog and readme entries * Adding the deprecation function to methods * Update changelog.txt Co-authored-by: daledupreez <[email protected]> * Readme entry update --------- Co-authored-by: daledupreez <[email protected]>
1 parent 257a3d4 commit 661cf26

File tree

5 files changed

+8
-56
lines changed

5 files changed

+8
-56
lines changed

changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
*** Changelog ***
22

33
= 9.5.1 - xxxx-xx-xx =
4+
* Fix - Stop checking for detached subscriptions for admin users, as it was slowing down wp-admin
45
* Fix - Fix fatal error when checking for a payment method availability using a specific order ID.
56

67
= 9.5.0 - 2025-05-13 =

includes/admin/class-wc-stripe-admin-notices.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,6 @@ public function admin_notices() {
6666
// All other payment methods.
6767
$this->payment_methods_check_environment();
6868

69-
// Subscription related checks.
70-
if ( WC_Stripe_Subscriptions_Helper::is_subscriptions_enabled() ) {
71-
$this->subscriptions_check_environment();
72-
}
73-
7469
foreach ( (array) $this->notices as $notice_key => $notice ) {
7570
echo '<div class="' . esc_attr( $notice['class'] ) . '" style="position:relative;">';
7671

@@ -467,8 +462,11 @@ public function payment_methods_check_environment() {
467462
* Environment check for subscriptions.
468463
*
469464
* @return void
465+
*
466+
* @deprecated 9.6.0 This method is no longer used and will be removed in a future version.
470467
*/
471468
public function subscriptions_check_environment() {
469+
_deprecated_function( __METHOD__, '9.6.0' );
472470
$options = WC_Stripe_Helper::get_stripe_settings();
473471
if ( 'yes' === ( $options['enabled'] ?? null ) && 'no' !== get_option( 'wc_stripe_show_subscriptions_notice' ) ) {
474472
$subscriptions = WC_Stripe_Subscriptions_Helper::get_some_detached_subscriptions();

includes/compat/class-wc-stripe-subscriptions-helper.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,11 @@ public static function is_subscriptions_enabled() {
2727
* Loads up to 50 subscriptions, and attempts to return up to 5 of those that are detached from the customer.
2828
*
2929
* @return array
30+
*
31+
* @deprecated 9.6.0 This method is no longer used and will be removed in a future version.
3032
*/
3133
public static function get_some_detached_subscriptions() {
34+
_deprecated_function( __METHOD__, '9.6.0' );
3235
// Check if we have a cached result.
3336
$cached_subscriptions = get_transient( self::DETACHED_SUBSCRIPTIONS_TRANSIENT_KEY );
3437
if ( ! empty( $cached_subscriptions ) ) {

readme.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ If you get stuck, you can ask for help in the [Plugin Forum](https://wordpress.o
111111
== Changelog ==
112112

113113
= 9.5.1 - xxxx-xx-xx =
114+
* Fix - Stop checking for detached subscriptions for admin users, as it was slowing down wp-admin
114115
* Fix - Fix fatal error when checking for a payment method availability using a specific order ID.
115116

116117
[See changelog for full details across versions](https://raw.githubusercontent.com/woocommerce/woocommerce-gateway-stripe/trunk/changelog.txt).

tests/phpunit/compat/test-class-wc-stripe-subscriptions-helper.php

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -17,55 +17,4 @@ class WC_Stripe_Subscriptions_Helper_Test extends WP_UnitTestCase {
1717
public function test_is_subscriptions_enabled() {
1818
$this->assertTrue( WC_Stripe_Subscriptions_Helper::is_subscriptions_enabled() );
1919
}
20-
21-
/**
22-
* Test for `get_some_detached_subscriptions`.
23-
*
24-
* @return void
25-
*/
26-
public function test_get_some_detached_subscriptions() {
27-
$subscription_id = 1;
28-
$customer_id = 'cus_123';
29-
$source_id = 'src_123';
30-
31-
$subscription = new WC_Subscription();
32-
$subscription->set_id( $subscription_id );
33-
$subscription->set_status( 'active' );
34-
$subscription->save();
35-
36-
$subscription->update_meta_data( '_stripe_customer_id', $customer_id );
37-
$subscription->update_meta_data( '_stripe_source_id', $source_id );
38-
$subscription->save_meta_data();
39-
40-
WC_Subscriptions_Helpers::$wcs_get_subscriptions = [ $subscription ];
41-
42-
// Mock response from Stripe API.
43-
$test_request = function () {
44-
return [
45-
'response' => 200,
46-
'headers' => [ 'Content-Type' => 'application/json' ],
47-
'body' => wp_json_encode(
48-
[
49-
'customer' => null,
50-
]
51-
),
52-
];
53-
};
54-
55-
add_filter( 'pre_http_request', $test_request, 10, 3 );
56-
57-
$expected = [
58-
[
59-
'id' => $subscription_id,
60-
'customer_id' => $customer_id,
61-
'change_payment_method_url' => $subscription->get_change_payment_method_url(),
62-
],
63-
];
64-
$this->assertEquals( $expected, WC_Stripe_Subscriptions_Helper::get_some_detached_subscriptions() );
65-
66-
remove_filter( 'pre_http_request', $test_request, 10, 3 );
67-
68-
// Test cached version
69-
$this->assertEquals( $expected, WC_Stripe_Subscriptions_Helper::get_some_detached_subscriptions() );
70-
}
7120
}

0 commit comments

Comments
 (0)