【发布时间】:2016-06-17 22:22:24
【问题描述】:
我在 WooCommerce 中发送自定义电子邮件时遇到问题。
这是错误:
致命错误:不能将 WC_Order 类型的对象用作
中的数组 /home/wp-content/themes/structure/functions.php 第 548 行
我的客户希望在每次客户订购和付款时发送自定义电子邮件,除了标准的订单确认电子邮件。
这是我的代码:
$order = new WC_Order( $order_id );
function order_completed( $order_id ) {
$order = new WC_Order( $order_id );
$to_email = $order["billing_address"];
$headers = 'From: Your Name <your@email.com>' . "\r\n";
wp_mail($to_email, 'subject', 'This is custom email', $headers );
}
add_action( 'woocommerce_payment_complete', 'order_completed' )
我也尝试了"woocommerce_thankyou" 钩子而不是"woocommerce_payment_complete",但仍然无法正常工作。
我使用的 Wordpress 版本是 4.5.2,WooCommerce 版本是 2.6.1。
【问题讨论】:
-
Woocommerce 新订单电子邮件发送工作..?
-
通过 PHP mail() 函数发送的电子邮件工作..?或 smtp
标签: php wordpress woocommerce orders email-notifications