最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

WooCommerce: The model of e-mail is displaying only the html, not css

programmeradmin2浏览0评论
Closed. This question is off-topic. It is not currently accepting answers.

Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.

Closed 3 years ago.

Improve this question

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:

The current result is:

I expect something like this:

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


Edit: The HTML of my email template: 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.

PHP Version 7.3.1

Closed. This question is off-topic. It is not currently accepting answers.

Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.

Closed 3 years ago.

Improve this question

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:

The current result is:

I expect something like this:

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


Edit: The HTML of my email template: https://pastebin/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.

PHP Version 7.3.1

Share Improve this question edited Jun 11, 2019 at 13:01 Lucas Vendramini asked Jun 10, 2019 at 21:09 Lucas VendraminiLucas Vendramini 3032 silver badges11 bronze badges 7
  • 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 Commented Jun 11, 2019 at 1:16
  • Thanks for support, @SallyCJ, here it is: pastebin/41TY84NS – Lucas Vendramini Commented Jun 11, 2019 at 11:50
  • What's the PHP version on your site? – Sally CJ Commented Jun 11, 2019 at 12:14
  • PHP Version 7.3.1 – Lucas Vendramini Commented Jun 11, 2019 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 Commented Jun 11, 2019 at 12:56
 |  Show 2 more comments

1 Answer 1

Reset to default 1

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/woocommerce/woocommerce/master/CHANGELOG.txt

Here is the template in WooCommerce in version 3.5.2:

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!


Workaround:

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:

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

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

    return $emails;
});


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

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

    return $style;
});

Class Emogrifier v2.0.0:

https://pastebin/U0eAFXpx

发布评论

评论列表(0)

  1. 暂无评论