我正在使用一个脚本的woocommerce,不发送续订电子邮件的零续期,但它是工作的客户电子邮件,我想相同的管理员可以谁可以帮助我Here is the link to script i am using
发布于 2021-06-08 03:59:44
这些是WooCommerce订阅中使用的以下电子邮件类。
$email_classes['WCS_Email_New_Renewal_Order'] = new WCS_Email_New_Renewal_Order();
$email_classes['WCS_Email_New_Switch_Order'] = new WCS_Email_New_Switch_Order();
$email_classes['WCS_Email_Processing_Renewal_Order'] = new WCS_Email_Processing_Renewal_Order();
$email_classes['WCS_Email_Completed_Renewal_Order'] = new WCS_Email_Completed_Renewal_Order();
$email_classes['WCS_Email_Customer_On_Hold_Renewal_Order'] = new WCS_Email_Customer_On_Hold_Renewal_Order();
$email_classes['WCS_Email_Completed_Switch_Order'] = new WCS_Email_Completed_Switch_Order();
$email_classes['WCS_Email_Customer_Renewal_Invoice'] = new WCS_Email_Customer_Renewal_Invoice();
$email_classes['WCS_Email_Cancelled_Subscription'] = new WCS_Email_Cancelled_Subscription();
$email_classes['WCS_Email_Expired_Subscription'] = new WCS_Email_Expired_Subscription();
$email_classes['WCS_Email_On_Hold_Subscription'] = new WCS_Email_On_Hold_Subscription();
WCS_Email_New_Switch_Order
和WCS_Email_New_Switch_Order
这是唯一向管理员发送电子邮件的类。
下面是在WCS_Email_New_Switch_Order
和WCS_Email_New_Switch_Order
中用来发送电子邮件的操作。
'woocommerce_order_status_pending_to_processing_renewal_notification'
'woocommerce_order_status_pending_to_completed_renewal_notification'
'woocommerce_order_status_pending_to_on-hold_renewal_notification'
'woocommerce_order_status_failed_to_processing_renewal_notification'
'woocommerce_order_status_failed_to_completed_renewal_notification'
'woocommerce_order_status_failed_to_on-hold_renewal_notification'
'woocommerce_order_status_cancelled_to_processing_renewal_notification'
'woocommerce_order_status_cancelled_to_completed_renewal_notification'
'woocommerce_order_status_cancelled_to_on-hold_renewal_notification'
'woocommerce_subscriptions_switch_completed_switch_notification'
因此,您还必须使用回调函数eg_maybe_remove_email
添加上述操作。检查下面的代码。
<?php
/*
Plugin Name: WooCommerce Subscriptions No $0 Emails
Plugin URI:
Description: Do not send a processing or completed renewal order emails to customers when the order or renewal is for $0.00.
Author:
Author URI:
Version: 0.1
*/
function eg_maybe_remove_email( $order_id ){
$order = new WC_Order( $order_id );
if ( 0 == $order->get_total() ) {
$email_class = array();
switch( current_filter() ) {
case 'woocommerce_order_status_completed_renewal_notification':
$email_class[] = 'WCS_Email_Completed_Renewal_Order';
break;
case 'woocommerce_order_status_pending_to_processing_renewal_notification':
$email_class[] = 'WCS_Email_Processing_Renewal_Order';
$email_class[] = 'WCS_Email_New_Renewal_Order';
break;
case 'woocommerce_order_status_failed_renewal_notification':
$email_class[] = 'WCS_Email_Customer_Renewal_Invoice';
$email_class[] = 'WCS_Email_New_Renewal_Order';
break;
case 'woocommerce_order_status_pending_to_completed_renewal_notification':
case 'woocommerce_order_status_pending_to_on-hold_renewal_notification':
case 'woocommerce_order_status_failed_to_processing_renewal_notification':
case 'woocommerce_order_status_failed_to_completed_renewal_notification':
case 'woocommerce_order_status_failed_to_on-hold_renewal_notification':
case 'woocommerce_order_status_cancelled_to_processing_renewal_notification':
case 'woocommerce_order_status_cancelled_to_completed_renewal_notification':
case 'woocommerce_order_status_cancelled_to_on-hold_renewal_notification':
$email_class[] = 'WCS_Email_New_Renewal_Order';
break;
case 'woocommerce_subscriptions_switch_completed_switch_notification':
$email_class[] = 'WCS_Email_New_Switch_Order';
break;
default:
$email_class[] = array();
break;
}
if ( ! empty( $email_class ) ) {
foreach ( $email_class as $key => $email ) {
remove_action( current_filter(), array( WC()->mailer()->emails[ $email ], 'trigger' ) );
}
}
}
}
//customer
add_action( 'woocommerce_order_status_completed_renewal_notification', 'eg_maybe_remove_email', 0, 1 );
add_action( 'woocommerce_order_status_pending_to_processing_renewal_notification', 'eg_maybe_remove_email', 0, 1 );
add_action( 'woocommerce_order_status_failed_renewal_notification', 'eg_maybe_remove_email', 0, 1 );
//admin
add_action( 'woocommerce_order_status_pending_to_completed_renewal_notification', 'eg_maybe_remove_email', 0, 1 );
add_action( 'woocommerce_order_status_pending_to_on-hold_renewal_notification', 'eg_maybe_remove_email', 0, 1 );
add_action( 'woocommerce_order_status_failed_to_processing_renewal_notification', 'eg_maybe_remove_email', 0, 1 );
add_action( 'woocommerce_order_status_failed_to_completed_renewal_notification', 'eg_maybe_remove_email', 0, 1 );
add_action( 'woocommerce_order_status_failed_to_on-hold_renewal_notification', 'eg_maybe_remove_email', 0, 1 );
add_action( 'woocommerce_order_status_cancelled_to_processing_renewal_notification', 'eg_maybe_remove_email', 0, 1 );
add_action( 'woocommerce_order_status_cancelled_to_completed_renewal_notification', 'eg_maybe_remove_email', 0, 1 );
add_action( 'woocommerce_order_status_cancelled_to_on-hold_renewal_notification', 'eg_maybe_remove_email', 0, 1 );
add_action( 'woocommerce_subscriptions_switch_completed_switch_notification', 'eg_maybe_remove_email', 0, 1 );
https://stackoverflow.com/questions/67877663
复制相似问题