脚本宝典收集整理的这篇文章主要介绍了php – 自定义电子邮件未在WooCommerce中完成订单完成,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
@H_419_7@除了标准订单确认电子邮件之外,我的客户希望在每次客户订购和付款时发送自定义电子邮件.
@H_419_7@这是我的代码:@H_419_7@
$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' )@H_419_7@我也试过“woocommerce_thankyou”钩子而不是“woocommerce_payment_complete”,但仍然无法正常工作.
@H_419_7@
add_action( 'woocommerce_payment_complete','order_completed_custom_email_notification' ) function order_completed_custom_email_notification( $order_id ) { $current_user = wp_get_current_user(); $user_email = $current_user->user_email; $to = sanITize_email( $user_email ); $headers = 'From: Your Name <your@email.com>' . "\r\n"; wp_mail($to,$headers ); }@H_419_7@最后,您必须在托管服务器上测试所有这些,而不是在计算机上使用localhost.在localhost上发送邮件在大多数情况下都不起作用……
以上是脚本宝典为你收集整理的php – 自定义电子邮件未在WooCommerce中完成订单完成全部内容,希望文章能够帮你解决php – 自定义电子邮件未在WooCommerce中完成订单完成所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。