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(ras-acc): add donation cancellation email template #3056

Merged

Conversation

chickenn00dle
Copy link
Contributor

@chickenn00dle chickenn00dle commented Apr 10, 2024

All Submissions:

Changes proposed in this Pull Request:

Closes https://app.asana.com/0/1206810965479792/1205743341940640/f

This PR adds a new donation cancellation email:

Screenshot 2024-04-10 at 15 40 37

Screenshot 2024-04-10 at 15 39 30

Note: I've populated the cancellation email with super basic copy based mostly off of the email template for receipt. Since we are revisiting email design in ras-acc and this is going into epic/ras-acc, I think this is fine for now. If it's alright, I'd like to address updating the email content if necessary in https://app.asana.com/0/1205234045751551/1205668937699542/f where we will be updating all transactional emails. Scratch that, I found the copy for this here https://newspackdesignp2.wordpress.com/2023/12/05/cancellation-emails/. I will still be addressing the design updates in another pr, so this PR only gets the email setup with the old design.

How to test the changes in this Pull Request:

  1. Go to Newspack > Reader Revenue > Emails
  2. Confirm a new Cancellation email is present as pictured above
  3. Select the edit link
  4. Confirm the email template post is populated with content relevant to donation cancellation
  5. Make some changes to the post and update
  6. Go back to the reader revenue emails menu
  7. Select the reset link for the Cancellation email
  8. Select the edit link once again and confirm your changes have been reset to default
  9. As a reader, trigger a donation cancellation email by purchasing a recurring donation then cancelling via my account
  10. Confirm you receive a cancellation email and its contents appear as expected (pictured above)
  11. As a site admin, disable the cancellation email and repeat step 9
  12. Confirm no cancellation email is sent

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 marked this pull request as ready for review April 10, 2024 19:51
@chickenn00dle chickenn00dle requested a review from a team as a code owner April 10, 2024 19:51
@chickenn00dle chickenn00dle added the [Status] Needs Review The issue or pull request needs to be reviewed label Apr 11, 2024
@chickenn00dle chickenn00dle force-pushed the feat/add-subscription-cancellation-email-template branch from a7c8b2f to ef078c6 Compare April 15, 2024 21:35
@chickenn00dle chickenn00dle force-pushed the feat/add-subscription-cancellation-email-template branch from 6e3d8b2 to e5b4422 Compare April 16, 2024 14:51
@chickenn00dle chickenn00dle requested a review from adekbadek April 16, 2024 14:53
Copy link
Member

@adekbadek adekbadek left a comment

Choose a reason for hiding this comment

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

Pre-approving pending a small tweak.

: __(
'This email is not active. The default receipt will be used.',
'newspack-plugin'
);
Copy link
Member

Choose a reason for hiding this comment

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

This should rather be the other way around – if the type is receipt, use the message about the default receipt. Otherwise, use the generic message.

Copy link
Contributor Author

@chickenn00dle chickenn00dle Apr 17, 2024

Choose a reason for hiding this comment

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

This should rather be the other way around – if the type is receipt, use the message about the default receipt. Otherwise, use the generic message.

Do you mean this should be changed to:

const notification =
    email.type === 'receipt'
        ? __(
            'This email is not active. The default receipt will be used.',
	    'newspack-plugin'
            )
        : __( 'This email is not active.', 'newspack-plugin' );

If so, this will have the same result as the current changes. On my end, it looks like the messaging is correct on the frontend as well:

Screenshot 2024-04-17 at 09 35 47

Or did you mean something else?

Copy link
Member

Choose a reason for hiding this comment

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

That's what I meant. The result is the same, but the code is more logical.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see. Happy to make the change if you feel that way! Done in 052255f

Copy link
Member

Choose a reason for hiding this comment

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

It's not about feelings, it's logic & readability:

type === 'receipt' ? notification_about_receipt : generic_notification

instead of

type === 'cancellation' ?  generic_notification : notification_about_receipt

As long as type can only be 'receipt' or 'cancellation' the former version seems fine, but it's not a good assumption to build on (there will be other types).

@github-actions github-actions bot added [Status] Approved The pull request has been reviewed and is ready to merge and removed [Status] Needs Review The issue or pull request needs to be reviewed labels Apr 17, 2024
@chickenn00dle chickenn00dle merged commit b5ade4f into epic/ras-acc Apr 18, 2024
7 checks passed
@chickenn00dle chickenn00dle deleted the feat/add-subscription-cancellation-email-template branch April 18, 2024 14:11
@matticbot
Copy link
Contributor

🎉 This PR is included in version 3.6.0-epic-ras-acc.7 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Copy link
Member

@adekbadek adekbadek left a comment

Choose a reason for hiding this comment

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

Since this is an epic branch, I did not submit an issue for this. But let me know if there's a better way.


$items = $subscription->get_items();
$item = array_shift( $items );
$is_donation = Donations::is_donation_product( $item->get_product_id() );
Copy link
Member

Choose a reason for hiding this comment

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

When deleting and account which has active subscriptions, this method will throw with

PHP Fatal error:  Uncaught Error: Call to a member function get_product_id() on null

because the $item is null at this point.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for catching this! I'll get a fix up for this today 👍

@matticbot
Copy link
Contributor

🎉 This PR is included in version 3.9.0-epic-ras-acc.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@matticbot
Copy link
Contributor

🎉 This PR is included in version 4.1.0-epic-ras-acc.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@matticbot
Copy link
Contributor

🎉 This PR is included in version 4.2.0-epic-ras-acc.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@matticbot
Copy link
Contributor

🎉 This PR is included in version 4.4.0-epic-ras-acc.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
released on @epic/ras-acc [Status] Approved The pull request has been reviewed and is ready to merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants