fix(wcs): account for more on-hold subscription cases #3710
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
All Submissions:
Changes proposed in this Pull Request:
See https://newspackengineering.wordpress.com/2025/01/10/accounting-for-all-on-hold-subscriptions/#comment-1691
This PR ensures our on-hold duration logic accounts for all of the following cases:
Transition to expired
Transition to trash
(The other cases in the p2 comment should already be accounted for.)
How to test the changes in this Pull Request:
Setup
You'll need to set up some subscriptions on a test site before beginning testing. Here are some useful tips for this part:
define( 'NEWSPACK_PREVENT_WC_ALLOW_FAILED_PAYMENT_RETRIES_OVERRIDE', true );
add_filter( 'newspack_subscriptions_expiration_enabled', '__return_false' );
, then follow these steps. Also use this filter to setup on-hold subscriptions with failed parent orders.wp shell
to manually fix the start and next_payment dates:Set up the following subscriptions (all within the on-hold duration except for the last on this list):
4000 0000 0000 0002
for example)Once you finish setting up, be sure to remove both the constant and filter before testing.
Testing
wp newspack migrate-expired-subscriptions --verbose
4000 0000 0000 0002
newspack_subscriptions_expiration_enabled
event via the action scheduler (WooCommerce > Status > Scheduled Actions > Pending)--live
flag) and verify all subscriptions behave as described above.Other information: