Skip to content

Conversation

@daledupreez
Copy link
Contributor

@daledupreez daledupreez commented Oct 23, 2025

Fixes STRIPE-751
Related to:

Changes proposed in this Pull Request:

This PR detects when we are running on WooCommerce Subscriptions staging sites as a way to detect whether we should detach customers from payment methods. This expands on our previous logic that only looked at the return value from wp_get_environment_type(). This PR does not implement a full fix for the issues flagged in #4131, but it does mean that staging sites using WooCommerce Subscriptions should behave better, at least when we're calling WC_Stripe_API::should_detach_payment_method_from_customer() in the code path.

Testing instructions

  • Apply a build containing the code from this PR/branch to your site
  • Ensure WooCommerce Subscriptions is installed and active on the site
  • Ensure you are in live mode, either by creating a live connection or by setting the testmode sub-option to no - wp option patch update woocommerce_stripe_settings testmode no
  • Without making other changes, access the WP CLI shell via wp shell
  • Run the following command to confirm the default behaviour:
return WC_Stripe_API::should_detach_payment_method_from_customer();
  • Verify that the return is true, which should be encoded as => bool(true) in the screen.
  • Add the following code snippet to force staging mode for WooCommerce Subscriptions:
add_filter( 'woocommerce_subscriptions_is_duplicate_site', '__return_true', 10, 1 );
  • Ensure your shell picks up the new code, which may require you to exit, and restart wp shell
  • Run the same command as above:
return WC_Stripe_API::should_detach_payment_method_from_customer();
  • Verify that this time the return value is false (encoded as => bool(false)).

  • Covered with tests (or have a good reason not to test in description ☝️)
  • [N/A] 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

@daledupreez daledupreez marked this pull request as ready for review November 4, 2025 08:10
@daledupreez daledupreez requested review from a team, malithsen and wjrosa and removed request for a team November 4, 2025 08:10
@daledupreez daledupreez self-assigned this Nov 4, 2025
Copy link
Contributor

@wjrosa wjrosa left a comment

Choose a reason for hiding this comment

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

Nice work, Dale! Code is good and works as intended

Copy link
Contributor

@malithsen malithsen left a comment

Choose a reason for hiding this comment

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

Looks good!

@daledupreez daledupreez merged commit 86ad249 into develop Nov 6, 2025
40 checks passed
@daledupreez daledupreez deleted the add/woo-subscription-staging-checks branch November 6, 2025 19:29
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.

4 participants