如何在 Woocommerce 中添加自定义电子邮件通知?
How to add custom email notification in Woocommerce?
如标题所述,是否有任何可能的方法来添加电子邮件通知,就像在取消订单时向客户发送电子邮件一样。
由于待付款的时间限制,我想通过电子邮件通知取消订单。
有什么办法吗??
您可以使用动作挂钩woocommerce_order_status_cancelled,当订单状态更改为已取消时执行此动作。
例如:
add_action('woocommerce_order_status_cancelled', function($order_id){
//send email here
}, 10, 1);
这里是 woocommerce_email_recipient_cancelled_order
过滤器钩子中的自定义钩子函数:
add_filter( 'woocommerce_email_recipient_cancelled_order', 'adding_customer_email_recipient_to_cancelled', 10, 2 );
function adding_customer_email_recipient_to_cancelled( $recipient, $order ){
if( is_admin() ) return $recipient;
$billing_email = $order->get_billing_email();
$recipient .= ', ' . $billing_email;
}
代码进入您的活动子主题(或主题)的 function.php 文件或任何插件文件。
此代码已经过测试并适用于 WooCommerce 3.0+
如标题所述,是否有任何可能的方法来添加电子邮件通知,就像在取消订单时向客户发送电子邮件一样。 由于待付款的时间限制,我想通过电子邮件通知取消订单。
有什么办法吗??
您可以使用动作挂钩woocommerce_order_status_cancelled,当订单状态更改为已取消时执行此动作。
例如:
add_action('woocommerce_order_status_cancelled', function($order_id){
//send email here
}, 10, 1);
这里是 woocommerce_email_recipient_cancelled_order
过滤器钩子中的自定义钩子函数:
add_filter( 'woocommerce_email_recipient_cancelled_order', 'adding_customer_email_recipient_to_cancelled', 10, 2 );
function adding_customer_email_recipient_to_cancelled( $recipient, $order ){
if( is_admin() ) return $recipient;
$billing_email = $order->get_billing_email();
$recipient .= ', ' . $billing_email;
}
代码进入您的活动子主题(或主题)的 function.php 文件或任何插件文件。
此代码已经过测试并适用于 WooCommerce 3.0+