Skip to content
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

feat(plugins): add url redirect for wc subscription renewals #3525

Open
wants to merge 8 commits into
base: trunk
Choose a base branch
from

Conversation

chickenn00dle
Copy link
Contributor

@chickenn00dle chickenn00dle commented Nov 5, 2024

All Submissions:

Changes proposed in this Pull Request:

Closes https://app.asana.com/0/1206274567818686/1208437232706180/f

This PR adds handling for a np_renewal param a new my-account/my-renewals endpoint to redirect readers to the first available pending renewal checkout, otherwise the subscriptions my account page:

Screenshot 2024-11-05 at 16 39 08

How to test the changes in this Pull Request:

  1. As a reader, purchase multiple subscriptions
  2. As admin, go to any subscription edit page for one of these subscriptions via WooCommerce > Subscriptions
  3. Create a renewal order for the subscription
    Screenshot 2024-11-05 at 16 41 21
  4. As the logged in reader, visit the my-account/my-renewals endpoint of your test site: site.url/my-account/my-renewals
  5. Confirm you are redirected to checkout for the renewal order in question
  6. As admin again, create another renewal order for another subscription belonging to this reader (there should now be two subscriptions that need payment)
  7. As reader again, visit the url from step 3 again
  8. This time confirm you are directed to the my account subscriptions page
    Screenshot 2024-11-06 at 18 19 15
  9. Complete checkout to re-activate the subscription. Then do the same for the second pending renewal (All subscriptions should be active).
  10. Visit the url from step 3 again.
  11. Confirm you are directed to the my account subscriptions page again
  12. Log out
  13. Visit the url from step 3 again.
  14. Confirm you are presented with a login form
  15. Login and confirm you are redirected to the my account subscriptions page once again.

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully ran tests with your changes locally?

@chickenn00dle chickenn00dle force-pushed the feat/add-subscriptions-renewal-redirect branch from 1bd87d5 to 3492424 Compare November 6, 2024 23:17
@chickenn00dle chickenn00dle marked this pull request as ready for review November 6, 2024 23:19
@chickenn00dle chickenn00dle requested a review from a team as a code owner November 6, 2024 23:19
@chickenn00dle chickenn00dle force-pushed the feat/add-subscriptions-renewal-redirect branch from 3492424 to f70d25b Compare November 6, 2024 23:21
@@ -113,7 +113,9 @@ window.newspackRAS.push( function ( readerActivation ) {
/** If there's a pre-auth, signing in redirects to the reader account. */
if ( reader?.email && ! reader?.authenticated ) {
link.setAttribute( 'data-redirect', link.getAttribute( 'href' ) );
redirectInput.value = link.getAttribute( 'href' );
if ( ! redirectInput?.value ) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We should respect any pre-defined redirect values.

@@ -177,7 +179,7 @@ window.newspackRAS.push( function ( readerActivation ) {
emailInput.value = reader?.email || '';
}

if ( redirectInput && ev?.target?.getAttribute( 'data-redirect' ) ) {
if ( ev?.target?.getAttribute( 'data-redirect' ) && ! redirectInput?.value ) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same here re: respecting pre-defined redirect values

@chickenn00dle chickenn00dle added the [Status] Needs Review The issue or pull request needs to be reviewed label Nov 6, 2024
@chickenn00dle
Copy link
Contributor Author

Got some feedback here so removing the Needs Review label to work on this: 0-as-1208437232706180/1208702687864921/f

@chickenn00dle chickenn00dle removed the [Status] Needs Review The issue or pull request needs to be reviewed label Nov 7, 2024
@chickenn00dle chickenn00dle force-pushed the feat/add-subscriptions-renewal-redirect branch from f70d25b to e29b3a3 Compare November 13, 2024 22:42
@miguelpeixe miguelpeixe self-requested a review November 14, 2024 16:00
@chickenn00dle chickenn00dle force-pushed the feat/add-subscriptions-renewal-redirect branch from e29b3a3 to eabb518 Compare November 14, 2024 16:26
@chickenn00dle
Copy link
Contributor Author

Added some changes to make the redirect happen via a new my-account endpoint my-renewals. Also updated the testing instructions.

Just awaiting feedback to verify the expected behavior before marking this one ready for review.

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.

1 participant