Skip to content
This repository was archived by the owner on May 21, 2025. It is now read-only.

In our customer notification emails, only display the subscription that is about to renew or expire, don't show all subscriptions purchased in the parent order. #722

Merged
merged 6 commits into from
Nov 13, 2024

Conversation

mattallan
Copy link
Contributor

@mattallan mattallan commented Nov 13, 2024

Fixes #721

Description

While testing the new Customer Notification feature I noticed that in the table under "Subscription Information", it contained all of my subscriptions that I purchased in the parent/initial order.

For example, I purchased a weekly and an "every 2 days" subscription in the same order, and then processed the "upcoming renewal order" email for just the weekly subscription. When I viewed the email it the subscriptions table contained both of my subscriptions which is not correct:

image

We don't really have a function available which displays a single subscription info table, therefore this PR introduces a new function to fill this gap. The new WC_Subscriptions_Email::subscription_details() function added in this PR is similar to our existing WC_Subscriptions_Email::order_details() function and can be used to load the subscriptions-info.php template for single or multiple subscriptions.

How to test this PR

Note

To test customer notifications you will need to either:

  1. Add return true; at the top of should_send_reminder_email() , or
  2. Add define( 'WP_ENVIRONMENT_TYPE', 'production' ); to your wp-config.php file

You will also need a way to test receiving an email. For testing locally, I just use the WP Mail Logging plugin.

  1. Go to WooCommerce > Settings > Subscriptions and enable the new Customer Notifications feature
  2. Add a weekly and monthly subscription product to your cart and go successfully through the checkout
  3. While on trunk, go to the Edit Subscription page for the weekly Subscription and use the actions to run "Send upcoming renewal notification".
  4. View the email and notice that both subscriptions are listed under "Subscription Information" the upcoming renewal email ❌
  5. Switch to this branch and confirm only the relevant subscription is listed in the email

Product impact

  • Added changelog entry (or does not apply)
  • Will this PR affect WooCommerce Subscriptions? yes/no/tbc, add issue ref
  • Will this PR affect WooCommerce Payments? yes/no/tbc, add issue ref
  • Added deprecated functions, hooks or classes to the spreadsheet

@mattallan mattallan requested a review from a team November 13, 2024 07:59
@xristos3490 xristos3490 self-requested a review November 13, 2024 14:37
Copy link
Member

@xristos3490 xristos3490 left a comment

Choose a reason for hiding this comment

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

Nice catch, and thanks for the swift PR, @mattallan!

This is testing well on my end! Here's the before and after:

Before After
Screenshot 2024-11-13 at 4 36 19 PM Screenshot 2024-11-13 at 4 37 33 PM

Copy link
Contributor

@Mayisha Mayisha left a comment

Choose a reason for hiding this comment

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

Thanks for the fix @mattallan. This is working perfectly as described.

Before

Screenshot 2024-11-13 at 8 54 36 PM

After

Screenshot 2024-11-13 at 8 54 16 PM

@mattallan
Copy link
Contributor Author

Thanks @xristos3490 and @Mayisha !

@mattallan mattallan merged commit 6783f11 into trunk Nov 13, 2024
9 checks passed
@mattallan mattallan deleted the fix/721-customer-notification-subscriptions-info branch November 13, 2024 20:48
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The "Subscription Info" table displayed in customer notification emails shows all subscriptions purchased in the parent/initial order
3 participants