将客户添加为 woocommerce 订阅取消订阅电子邮件的收件人(通知)

问题描述 投票:0回答:1

默认情况下,woocommerce 订阅仅向商店管理员发送订阅已取消的电子邮件通知,而不是向客户发送。这对用户来说并不友好。我正在尝试将客户添加为此特定电子邮件通知的收件人,但到目前为止尚未成功。

我尝试编写使用 PhP 添加过滤器到操作 cancelled_subscription_notification 。我相信它可以处理取消订阅的电子邮件通知。

add_filter( 'cancelled_subscription_notification', 
'wc_cancelled_order_add_customer_email', 10, 2 );
function wc_cancelled_order_add_customer_email( $recipient, $order ){
// Avoiding errors in backend (mandatory when using $order argument)
if ( ! is_a( $order, 'WC_Order' ) ) return $recipient;

  // Get the customer ID
$user_id = $order->get_user_id();

// Get the user data
$user_data = get_userdata( $user_id );

return $recipient;
}

使用此代码(在functions.php中添加)时,当我取消订阅时,我收到错误500(也不会发送给管理员的实际电子邮件!)。

也许有用:https://github.com/wp-premium/woocommerce-subscriptions/blob/master/includes/emails/class-wcs-email-cancelled-subscription.php(链接到已取消的订阅调用)

woocommerce email-notifications woocommerce-subscriptions
1个回答
0
投票

这对我有用。我在 woocommerce_subscription_status_updated 中执行此操作,但这会导致异常错误,并以某种方式丢失parent_id。

`// send customer email on subscription updated

add_filter('woocommerce_email_recipient_cancelled_subscription', 'set_customer_as_cancelled_subscription_recipient', 10, 2); 函数 set_customer_as_cancelled_subscription_recipient($recipient, $subscription) { 返回$订阅? $subscription->get_billing_email() : $recipient; }`

© www.soinside.com 2019 - 2024. All rights reserved.