I'm using the version 3.4.7 of WooCommerce and configuring the e-mails, I stare with a strange thing: the templates didn't appear the css. I experienced this in all of my sites, this is a test site that is installed WordPress and WooCommerce and nothing more.

Here is my config:

Image with my config

The current result is:

current result of my template

I expect something like this:

enter image description here

I don't know what I'm doing wrong. Thanks for help.

Edit: The HTML of my email template: https://pastebin.com/41TY84NS Note: i'm not using any custom template of my theme, it's storefront theme, i tested with twenty-seventeen and gives the same error.

dom extension enabled

PHP Version 7.3.1

  • 2
    Click on the link to preview the email template and view the HTML source, and share it on Pastebin if necessary. If everything is good, you should see inline CSS code in the HTML - e.g. style="background-color: #f7f7f7; margin: 0; ...". – Sally CJ Jun 11 '19 at 1:16
  • Thanks for support, @SallyCJ, here it is: pastebin.com/41TY84NS – Lucas Vendramini Jun 11 '19 at 11:50
  • What's the PHP version on your site? – Sally CJ Jun 11 '19 at 12:14
  • PHP Version 7.3.1 – Lucas Vendramini Jun 11 '19 at 12:15
  • I'm testing it in XAMPP: Yes, It's enabled C:\xampp\htdocs\market\dom-check.php:1:boolean true. As I said in description, I tested in 2 of my sites and gives the same error. My theory is that WooCommerce 3.4.7 maybe is having this problem with email templates. Don't know, I will test it up. – Lucas Vendramini Jun 11 '19 at 12:56

Well, I tested a lot of WooCommerce versions (3.3.x, 3.4.x and 3.5.x) using WP Rollback and I believe that was a error in e-mail templates that was fixed in version 3.5.2. I didn't found nothing in the changelog about that: https://raw.githubusercontent.com/woocommerce/woocommerce/master/CHANGELOG.txt

Here is the template in WooCommerce in version 3.5.2:

template with css

I have to investigate more deeply to know what is is, but the versions below 3.5.2 is throwing this error:

[11-Jun-2019 13:46:09 UTC] PHP Warning:  preg_replace(): Compilation failed: invalid range in character class at offset 39 in C:\xampp\htdocs\market\wp-content\plugins\woocommerce\includes\libraries\class-emogrifier.php on line 1504
[11-Jun-2019 13:46:09 UTC] PHP Stack trace:
[11-Jun-2019 13:46:09 UTC] PHP   1. {main}() C:\xampp\htdocs\market\wp-admin\index.php:0
[11-Jun-2019 13:46:09 UTC] PHP   2. require_once() C:\xampp\htdocs\market\wp-admin\index.php:10
[11-Jun-2019 13:46:09 UTC] PHP   3. do_action() C:\xampp\htdocs\market\wp-admin\admin.php:156
[11-Jun-2019 13:46:09 UTC] PHP   4. WP_Hook->do_action() C:\xampp\htdocs\market\wp-includes\plugin.php:453
[11-Jun-2019 13:46:09 UTC] PHP   5. WP_Hook->apply_filters() C:\xampp\htdocs\market\wp-includes\class-wp-hook.php:310
[11-Jun-2019 13:46:09 UTC] PHP   6. WC_Admin->preview_emails() C:\xampp\htdocs\market\wp-includes\class-wp-hook.php:286
[11-Jun-2019 13:46:09 UTC] PHP   7. WC_Email->style_inline() C:\xampp\htdocs\market\wp-content\plugins\woocommerce\includes\admin\class-wc-admin.php:210
[11-Jun-2019 13:46:09 UTC] PHP   8. Emogrifier->emogrify() C:\xampp\htdocs\market\wp-content\plugins\woocommerce\includes\emails\class-wc-email.php:530
[11-Jun-2019 13:46:09 UTC] PHP   9. Emogrifier->createAndProcessXmlDocument() C:\xampp\htdocs\market\wp-content\plugins\woocommerce\includes\libraries\class-emogrifier.php:291
[11-Jun-2019 13:46:09 UTC] PHP  10. Emogrifier->process() C:\xampp\htdocs\market\wp-content\plugins\woocommerce\includes\libraries\class-emogrifier.php:327
[11-Jun-2019 13:46:09 UTC] PHP  11. Emogrifier->translateCssToXpath() C:\xampp\htdocs\market\wp-content\plugins\woocommerce\includes\libraries\class-emogrifier.php:369
[11-Jun-2019 13:46:09 UTC] PHP  12. Emogrifier->translateCssToXpathPass() C:\xampp\htdocs\market\wp-content\plugins\woocommerce\includes\libraries\class-emogrifier.php:1448
[11-Jun-2019 13:46:09 UTC] PHP  13. Emogrifier->translateCssToXpathPassWithMatchClassAttributesCallback() C:\xampp\htdocs\market\wp-content\plugins\woocommerce\includes\libraries\class-emogrifier.php:1472
[11-Jun-2019 13:46:09 UTC] PHP  14. preg_replace() C:\xampp\htdocs\market\wp-content\plugins\woocommerce\includes\libraries\class-emogrifier.php:1504

Thanks for @SallyCJ for patience and support!


I got the class that is working from 3.5.2 and used that class in my theme. So doing this you will be able to fix the error in 3.5.1 and lower versions of WooCommerce:

add_filter( 'woocommerce_email_classes', function($emails){

    require_once get_template_directory() . '/class-emogrifier.php';

    return $emails;

add_filter( 'woocommerce_email_styles', function($style){

    require_once get_template_directory() . '/class-emogrifier.php';

    return $style;

Class Emogrifier v2.0.0:


  • 1
    Well, you could try asking on the WooCommerce support forums or post a ticket on their GitHub page.. but it's always recommended to use the latest version of WooCommerce or any other plugins. :) – Sally CJ Jun 11 '19 at 14:15
  • Yes, I will contact theirs support. I would like to use the last version, but the problem is that I have plugins I've made and I have to support them, They're compatible with 3.4.7. If I update WooCommerce they will break because there are hooks of WooCommerce that changed the name and etc. I have a big job to do if I update it now. I have a theme to mantain too. – Lucas Vendramini Jun 11 '19 at 14:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.