如何在woocommerce中向新注册的用户发送优惠券代码?
答案 0 :(得分:3)
以下代码将帮助您向woocommerce中新注册的用户发送邮件。
add_action('woocommerce_created_customer','wdm_custom_new_user_action',10,3);
function wdm_custom_new_user_action($customer_id, $new_customer_data, $password_generated){
$to= $new_customer_data['user_email'];
$subject='Your free Coupon new registration';
$message="Here is Your free coupon id : newBee45 ";
$headers="Content-Type: text/html\r\n";
$attachments="";
wp_mail( $to, $subject, $message, $headers, $attachments );
}
将此功能添加到您的自定义插件或子主题中,以确保它不会在主题/插件更新时被删除。
测试过相同。如果同样适合您,请告诉我。