Php 将订单号添加到电子邮件正文模板中的字符串
我正在尝试更改保留电子邮件,以便在介绍中包含订单号 我添加了“$order->get_id()”来显示订单号。不太管用。有什么想法吗Php 将订单号添加到电子邮件正文模板中的字符串,php,wordpress,woocommerce,orders,email-templates,Php,Wordpress,Woocommerce,Orders,Email Templates,我正在尝试更改保留电子邮件,以便在介绍中包含订单号 我添加了“$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> 这是
<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>
这是因为它现在被视为字符串的一部分,它缺少连接运算符('.')
更多信息:
像这样使用它
<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>
但是
编辑 另一个选择:看,
双重回答,同时发布这是因为它现在被视为字符串的一部分,它缺少连接运算符
('.')
更多信息:
像这样使用它
<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>
但是
编辑 另一个选择:看,
双重回答,同时发布您需要在字符串中连接订单号…您可以更好地使用
printf()
和WC\u order
方法get\u order\u 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>
您需要在字符串中串联订单号…您可以更好地使用printf()
和WC\u order
方法get\u order\u 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>