问题描述
我希望设置一个会员计划,从电子邮件通知开始,例如当某人应用会员用户的优惠券代码时。
I'm looking to setup an affiliate program, starting with the email notifications like when someone applies the coupon code of a an affiliate user.
例如:
- 客户应用的优惠券代码鲍勃。
- 有关客户在购物车或结帐时应用的优惠券代码 bob的电子邮件通知被发送到 [email protected](关联公司),在订购前已提交。
- Coupon code "Bob" applied by a customer.
- An email notification is sent to "[email protected]" (an affiliate) about the coupon code "bob" applied by a customer in cart or checkout, before order is submitted.
我尝试使用(没有任何运气): $ order-> get_used_coupons()
然后,一旦完成订单,将再次发送电子邮件通知:完整的独家代码。
Then once order is completed, an email notification will be sent again: "order was completed with exclusive code".
推荐答案
您可以尝试使用挂钩在 woocommerce_applied_coupon $ c $中的自定义函数c>
操作挂钩(每次应用优惠券时触发)。
You can try to use a custom function hooked in woocommerce_applied_coupon
action hook (fired each time a coupon is applied).
这里只是一个功能示例,当应用优惠券时,该电子邮件将发送电子邮件(电子邮件地址名称收件人已设置了优惠券名称)。
Here is just a functional example that will send an email when a coupon is applied (the email address name recipient is set with the coupon name).
您将需要根据需要对其进行自定义:
You will need to customize it for your needs:
add_action( 'woocommerce_applied_coupon', 'custom_email_on_applied_coupon', 10, 1 );
function custom_email_on_applied_coupon( $coupon_code ){
if( $coupon_code == 'bob' ){
$to = "[email protected]"; // Recipient
$subject = sprintf( __('Coupon "%s" has been applied'), $coupon_code );
$content = sprintf( __('The coupon code "%s" has been applied by a customer'), $coupon_code );
wp_mail( $to, $subject, $content );
}
}
代码进入function.php文件您的活动子主题(或主题)或任何插件文件中。
这篇关于在WooCommerce中应用特定优惠券代码时发送电子邮件通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!