-
Notifications
You must be signed in to change notification settings - Fork 58
fix: hide 'trashed' subscriptions from My Account #4351
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
Conversation
miguelpeixe
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This tested well, but I think we can go for a simpler approach. The user subscription list and "Subscriptions/My Subscription" button rely on wcs_get_users_subscriptions(), which supports a hook.
Something like this should be enough:
add_filter(
'wcs_get_users_subscriptions',
function( $subscriptions ) {
if ( function_exists( 'is_account_page' ) && is_account_page() ) {
$subscriptions = array_filter(
$subscriptions,
function( $subscription ) {
return ! $subscription->has_status( 'trash' );
}
);
}
return $subscriptions;
},
10
);|
Oh, that's so much nicer - thanks @miguelpeixe! 🙌 I left a couple pieces of the original code in:
|
miguelpeixe
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for revising! 🙌
|
Hey @laurelfulford, good job getting this PR merged! 🎉 Now, the Please check if this PR needs to be included in the "Upcoming Changes" and "Release Notes" doc. If it doesn't, simply remove the label. If it does, please add an entry to our shared document, with screenshots and testing instructions if applicable, then remove the label. Thank you! ❤️ |
All Submissions:
Changes proposed in this Pull Request:
This PR hides trashed subscriptions from the My Account view.
If you only have trashed subscriptions, it hides the Subscriptions menu all together.
See: NPPM-2442
How to test the changes in this Pull Request:
4000 0000 0000 0341(which will result in a failed payment).npm run build.Other information: