我注意到客戶暫停訂單電子郵件不可用,因此我試圖用一個操作替換髮送相應電子郵件的操作。以編程方式重新發送WooCommerce customer_on_hold_order電子郵件通知
這似乎工作,除了保持狀態。我沒有看到持有和處理案例之間的區別是什麼,除了$available_emails
,class-wc-meta-box-order-actions.php
之外,我已經刪除了所有其他的,他們仍然工作。
我做錯了什麼?這是否可以使這成爲可能?
我的代碼是:
function ulmh_resend1($actions) {
$actions['ulmh_resend'] = __('Resend Email', 'text_domain');
return $actions;
}
function ulmh_resend2($order) {
$mailer = WC()->mailer();
$mails = $mailer->get_emails();
if ($order->has_status('on-hold')) {
$eml = 'customer_on_hold_order';
}elseif ($order->has_status('processing')) {
$eml = 'customer_processing_order';
}elseif ($order->has_status('completed')) {
$eml = 'customer_completed_order';
} else {
$eml = "nothing";
}
if (! empty($mails)) {
foreach ($mails as $mail) {
if ($mail->id == eml) {
$mail->trigger($order->id);
}
}
}
}
function ulmh_resend3($order_emails) {
$remove = array('new_order', 'cancelled_order', 'customer_processing_order', 'customer_completed_order', 'customer_invoice');
$order_emails = array_diff($order_emails, $remove);
return $order_emails;
}
add_action('woocommerce_order_actions', 'ulmh_resend1');
add_action('woocommerce_order_action_ulmh_resend', 'ulmh_resend2');
add_filter('woocommerce_resend_order_emails_available', 'ulmh_resend3');
有什麼問題的時候,特別是?你的代碼中有什麼/不起作用? –
如果訂單處於處理或已完成狀態,但代碼處於正常狀態,但處於暫掛狀態時未發送電子郵件,則代碼可以正常工作。沒有消息出現在調試日誌中,它看起來好像customer_on_hold_order不在$郵件中,但原始電子郵件發送正確 –