You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
WooCommerce Square emails produce errors in WooCommerce email settings preview.
To Reproduce
Use WooCommerce 9.8.0-dev (or 9.7 Beta).
Enable the Email improvements feature flag in WooCommerce > Settings > Advanced > Features > Experimental features.
Enable WP_DEBUG.
Make sure WooCommerce Square is enabled.
Go to WooCommerce > Settings > Emails.
Scroll down to the email preview section.
Select an email template related to WooCommerce Square in the dropdown (Square sync completed, Square Gift Card sent).
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.
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
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.
Describe the bug
WooCommerce Square emails produce errors in WooCommerce email settings preview.
To Reproduce
WP_DEBUG
.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.
Screenshots
Expected behavior
WooCommerce Square email previews work correctly.
Desktop (please complete the following information):
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.
The text was updated successfully, but these errors were encountered: