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

Fix excessive emails when enabling the gateway #3695

Merged
merged 5 commits into from
Jan 9, 2025

Conversation

malithsen
Copy link
Contributor

Fixes #3660

Changes proposed in this Pull Request:

During payment gateway initialization, WC core add hooks that will get triggered when the main gateway is enabled. Use of a centralized option_key for all 'child gateways' makes WC core issue separate email notifications for all of them.
To sidestep this problem, with this change, we use separate option_key for each child gateway but still use the parent gateways settings when retrieving them.

Changes made:

  • Update get_option_key() to return settings specific to the Stripe ID.
  • Introduce get_option() method to fetch options from the main Stripe gateway.

Testing instructions

Test emails

  • In WooCommerce -> Settings -> Payments, toggle the Stripe gateway off and then back on. Make sure only a single email titled Payment gateway "Stripe" enabled is sent to the admin.

Regression tests

  • Enable all payment methods, save settings, refresh the page, confirm the settings are accurate. Verify payment method availability in the blocks/classic checkout pages.
  • Disable one specific PM and after save & refresh confirm the settings are accurate and checkout page is accurate.
  • Customize a payment method to add a custom title/description. Confirm the settings are saved and reflects on the blocks/classic checkout page.

  • Covered with tests (or have a good reason not to test in description ☝️)
  • Added changelog entry in both changelog.txt and readme.txt (or does not apply)
  • Tested on mobile (or does not apply)

Post merge

malithsen and others added 4 commits January 8, 2025 10:28
During payment gateway initialization, WC core add hooks that will get
triggered when the main gateway is enabled. Use of a centralized option_key for all
'child gateways' makes WC core issue separate email notifications for all of them. To sidestep this problem,
with this change we use separate option_id for each child gateway but still use the
parent gateways settings when retrieving them.

Changes made:
- Update get_option_key() to return settings specific to the Stripe ID.
- Introduce get_option() method to fetch options from the main Stripe gateway.
@malithsen malithsen requested review from a team and Mayisha and removed request for a team January 8, 2025 18:46
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 @malithsen 👍

  • Tested enabling/disabling different payment methods.
  • Tested customizing title and description of a payment method.
  • Tested enabling/disabling the main Stripe gateway and confirmed that only one email is sent after enabling the gateway.

Before

Screenshot 2025-01-09 at 6 57 12 PM

After

Screenshot 2025-01-09 at 9 05 42 PM

@malithsen
Copy link
Contributor Author

Failing e2e tests and QIT e2e tests don't appear to be related to the changes here.

@malithsen malithsen merged commit 73523d9 into develop Jan 9, 2025
35 of 37 checks passed
@malithsen malithsen deleted the fix/duplicate-emails branch January 9, 2025 15:23
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.

Enabling Stripe gateway in WooCommerce settings triggers multiple notification emails
2 participants