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

WooCommerce Square emails produce errors in WooCommerce email settings preview #292

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

Comments

@alex-mpoet
Copy link

Describe the bug

WooCommerce Square 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 Square is enabled.
  5. Go to WooCommerce > Settings > Emails.
  6. Scroll down to the email preview section.
  7. Select an email template related to WooCommerce Square in the dropdown (Square sync completed, Square Gift Card sent).
  8. Observe the errors. Examples:
    8.1. Function status was called incorrectly.
    8.2. Placeholders like {product_count}, {sync_completed_date}, {sync_completed_date} not replaced with dummy values.
    8.3. Undefined stdClass properties.
    8.3. Missing some content like gift card code.
  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
Image

Expected behavior

WooCommerce Square 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
@jeffpaul jeffpaul removed the type: bug The issue is a confirmed bug. label Feb 25, 2025
@jeffpaul jeffpaul added this to the Future Release milestone Feb 25, 2025
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

No branches or pull requests

2 participants