Skip to content

Subscription detached notice when viewing subscription #4393

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 16 commits into
base: add/subscriptions-detached-tool
Choose a base branch
from

Conversation

wjrosa
Copy link
Contributor

@wjrosa wjrosa commented Jun 4, 2025

Fixes STRIPE-500

Changes proposed in this Pull Request:

As part of STRIPE-483, this PR adds a new notice to the subscription edit page in wp-admin when the subscription payment method is detached. It also includes information about the new tool introduced in #4391

Notice preview:
Screenshot 2025-06-04 at 17 32 17

I am also taking the opportunity to introduce the new page helper class I created a POC for here.

Testing instructions

  • Checkout this branch on your test environment (add/single-subscription-detached-notice)
  • Install the subscriptions extension
  • Create a subscription for any user (perform a purchase or add using the admin interface) *
  • Comment out the lines handling the cache (includes/compat/class-wc-stripe-subscriptions-helper.php:53 and includes/compat/class-wc-stripe-subscriptions-helper.php:88)
  • Comment out the lines checking for the detachment, so all subscriptions can be returned (includes/compat/class-wc-stripe-subscriptions-helper.php:74 and includes/compat/class-wc-stripe-subscriptions-helper.php:77, also comment out the closing brackets to avoid breaking the block) *
  • Attempt to edit the subscription
  • Confirm the notice is displayed

* You can also purchase subscriptions as a shopper and detach their payment method using the Stripe dashboard instead.


  • Covered with tests (or have a good reason not to test in description ☝️)
  • Tested on mobile (or does not apply)

Changelog entry

  • This Pull Request does not require a changelog entry. (Comment required below)
Changelog Entry Comment

Comment

Post merge

@wjrosa wjrosa self-assigned this Jun 4, 2025
@wjrosa wjrosa marked this pull request as ready for review June 4, 2025 22:49
@wjrosa wjrosa requested review from a team and Mayisha and removed request for a team June 4, 2025 22:57
* @return bool
*/
public static function is_subscription_edit_page() {
if ( apply_filters( 'wc_stripe_is_subscription_edit_page', false ) ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious about why we are using this wc_stripe_is_subscription_edit_page filter in 3 places and what is the thought behind introducing this filter.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is basically used for unit tests. For some reason, I could not overwrite the check for the page using the query params. I tried multiple ways, but none worked. So I decided to use this filter instead.

I have improved the code in e4e48e1

Copy link

github-actions bot commented Jun 6, 2025

📈 PHP Unit Code Coverage Report

Package Line Rate Health
includes/class-wc-stripe-page-helper.php 83%
Summary 44% (7309 / 16450)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants