微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

将订单号添加到WooCommerce电子邮件正文模板中的字符串

如何解决将订单号添加到WooCommerce电子邮件正文模板中的字符串

我正在尝试更改保留的电子邮件,以在简介中包含订单号。

添加了“ $ order-> get_id()”以显示订单号。不太正常。有什么想法吗?

<p><?PHP esc_html_e( 'Thanks for your order. Your order number is $order->get_id(). Below you can find the contents of your order.','woocommerce' ); ?></p>

解决方法

这是因为它现在被视为字符串的一部分,缺少连接运算符('.')

更多信息:String Operators

改为使用它

<p><?php esc_html_e( 'Thanks for your order. Your order number is ' . $order->get_id() . ' Below you can find the contents of your order.','woocommerce' ); ?></p>

示例:

不是

'First part of string $myvar Second part of string';

但是

'First part of string' . $myvar . 'Second part of string';


编辑

另一个选项:请参见Loic's answer, 双重答案,同时发布

,

您需要将字符串中的订单号连接起来……可以更好地使用printf()WC_Order方法get_order_number(),如下所示:

<p><?php printf( esc_html__( 'Thanks for your order. Your order number is %s. Below you can find the contents of your order.','woocommerce' ),$order->get_order_number() ); ?></p>

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。