douzhanyan5015 2019-06-21 10:58
浏览 53

WooCommerce通知中的Echo功能被剥离

I am using a number of related WooCommerce plugins including WooCommerce Subscriptions and Events Tickets. The Events Tickets plugin has an add on plugin that adds event and attendee information to the WooCommerce order pages, including emails. On the WooCommerce Subscription specific emails, the CSS outputs directly to the mail, it's as if the echo function has been stripped. However, to contrast, on the non-subscription mails the CSS isn't output it simply doesn't add the styles. Here's how the stylesheet is being called in a function in the plugin:

echo '<style type="text/css">'; include( 'resources/tribe-attendee-meta-table.css' ); echo '</style>';

The CSS looks like this:

.woocommerce table a.event-title { font-size: 1.25em; font-style: italic; }

This seems to be added dynamically as an inline style. I have to say I am not how this is being applied, but led be to believe it was something to do with the style names:

.woocommerce table

So if I write the CSS this way:

a.event-title { font-size: 1.25em; font-style: italic; }

Then in the non-subscription notification email everything is added correctly as inline styles.

Unfortunately for the default subscription the CSS is being output to the page like this:

https://screencast.com/t/J7B8utYqs

To solve the issue I've simply disabled the styles being applied, since it doesn't make a major difference to how the mail looks, as long as the information is included.

I hope that provides enough information to help me look in the right area.

  • 写回答

1条回答 默认 最新

  • douchang8758 2019-06-21 12:20
    关注

    Personally, I don't like using it like this anyway but have you tried setting the CSS to a variable and then including it in the echo? It's not that the echo is being ignored, it's that the include is not echoing at all, it's doing exactly what it says on the tin, including the file.

    Try:

    $css = file_get_contents('resources/tribe-attendee-meta-table.css');
    echo "<style>" . $css . "</style>";
    

    p.s. I know there are a million ways to write this so syntax not important right now :)

    评论

报告相同问题?

悬赏问题

  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)