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

WCPay emails produce errors in WooCommerce email settings preview #10436

Open
alex-mpoet opened this issue Feb 25, 2025 · 2 comments
Open

WCPay emails produce errors in WooCommerce email settings preview #10436

alex-mpoet opened this issue Feb 25, 2025 · 2 comments
Labels

Comments

@alex-mpoet
Copy link

Describe the bug

WooCommerce Payments emails produce errors in WooCommerce email settings preview.

To Reproduce

  1. Use WooCommerce 9.8.0-dev (or 9.7 Beta).
  2. Enable the Email improvements feature flag in WooCommerce > Settings > Advanced > Features > Experimental features.
  3. Enable WP_DEBUG.
  4. Make sure WooCommerce Payments is enabled.
  5. Go to WooCommerce > Settings > Emails.
  6. Scroll down to the email preview section.
  7. Select an email template related to WooCommerce Payments in the dropdown (e.g. New receipt).
  8. Observe the errors. Examples:
    8.1. Many undefined array keys.
    8.2. Deprecation notices for function calls like ucfirst().
  9. Try changing global email template styles like colors, font, logo, header alignment, footer text and see if changes are applied to your plugin's templates. If you notice something else that is off in your plugin's email template previews, feel free to improve it as well.

Screenshots

Image

Expected behavior

WooCommerce Payments email previews work correctly.

Desktop (please complete the following information):

  • OS: Any OS
  • Browser: Any browser

Additional context

WooCommerce version: 9.8.0-dev
WordPress version: 6.7.2
Server info: PHP/8.3.14

Tips for fixing

Each error needs to be treated separately, but here are some general useful things.

Empty values, deprecation notices and general rendering errors are usually caused by missing email-specific variables in the preview, e.g. placeholder replacement values, custom email and order details etc. These variables can't be taken from the method that sends the actual email. Dummy values for the preview need to be explicitly provided by a plugin which adds its own email templates.

There is a new woocommerce_email_preview_placeholders filter to add more placeholders to be replaced that some of your emails may use.

Also, filters are now available to add additional data you might need for emails to be rendered properly in previews:
woocommerce_email_preview_dummy_order
woocommerce_email_preview_dummy_product
woocommerce_email_preview_dummy_address

Another group of filters is for adding support for custom fields and styles your emails might use: woocommerce_email_preview_email_content_setting_ids, woocommerce_email_preview_email_style_setting_ids.

Let me know if you need any more help in fixing the issues described above.

@alex-mpoet alex-mpoet added the type: bug The issue is a confirmed bug. label Feb 25, 2025
@alex-mpoet alex-mpoet changed the title WCPay emailss produce errors in WooCommerce email settings preview. WCPay emailss produce errors in WooCommerce email settings preview Feb 25, 2025
@alex-mpoet alex-mpoet changed the title WCPay emailss produce errors in WooCommerce email settings preview WCPay emails produce errors in WooCommerce email settings preview Feb 25, 2025
@haszari
Copy link
Contributor

haszari commented Feb 27, 2025

This likely affects most emails, so could be handled by various focus areas (account lifecycle, payment processing, payouts, disputes).

The payments / receipt emails are most critical / important, and highest impact, so I'm going with payment processing label.

@BurakParsAydin
Copy link
Contributor

@alex-mpoet @haszari It appears that the issue only occurs when selecting the 'New receipt' option, as you mentioned. I was unable to replicate similar errors with other email templates. I will investigate this further to identify the cause and will apply a fix if feasible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants