【发布时间】:2017-12-29 06:48:11
【问题描述】:
每当使用 PHP 为 Woocommerce 按下结帐按钮时,我都会尝试发送自定义电子邮件。
此电子邮件将与 wooCommerce 的电子邮件通知一起发送。 我使用了这个answer,并编辑了如下代码:
//execute some php on successfull checkout
add_action( 'woocommerce_payment_complete', 'so_32512552_payment_complete' );
function so_32512552_payment_complete( $order_id ){
$order = wc_get_order( $order_id );
foreach ( $order->get_items() as $item ) {
if ( $item['product_id'] > 0 ) {
$_product = $order->get_product_from_item( $item );
// the message
$msg = "First line of text\nSecond line of text";
// use wordwrap() if lines are longer than 70 characters
$msg = wordwrap($msg,70);
// send email
mail("info@example.com","My subject",$msg);
}
}
}
但似乎什么也没发生。有什么想法吗?
谢谢
【问题讨论】:
标签: php wordpress woocommerce checkout email-notifications