【发布时间】:2019-10-11 22:17:22
【问题描述】:
我有一个包含其他客户电子邮件帐户的自定义字段。
我的想法是,当订单更改状态 WAIT、PENDING、PROCESSING 或 COMPLETED 时,它将到达此字段中配置的电子邮件。
这可能吗?
没有需要编程的问题,但是不知道用什么钩子。
谢谢。
【问题讨论】:
标签: woocommerce
我有一个包含其他客户电子邮件帐户的自定义字段。
我的想法是,当订单更改状态 WAIT、PENDING、PROCESSING 或 COMPLETED 时,它将到达此字段中配置的电子邮件。
这可能吗?
没有需要编程的问题,但是不知道用什么钩子。
谢谢。
【问题讨论】:
标签: woocommerce
在您的活动主题的functions.php中添加以下代码sn-p -
function add_cc_to_wc_order_emails( $header, $mail_id, $mail_obj ) {
$available_for = array( 'customer_on_hold_order', 'customer_processing_order', 'customer_completed_order' );
if( in_array( $mail_id, $available_for ) ) {
$cc_email = 'addyour@ccmail.com';
$cc_username = "yourCCUser";
$formatted_email = utf8_decode( $cc_username . ' <' . $cc_email . '>' );
$header .= 'Cc: ' . $formatted_email . "\r\n";
}
return $header;
}
add_filter( 'woocommerce_email_headers', 'add_cc_to_wc_order_emails', 99, 3 );
【讨论】:
这可能非常有用: https://www.skyverge.com/blog/add-woocommerce-email-recipients-conditionally/ 我会看一下注意事项部分。
【讨论】:
例如,您可以使用woocommerce_order_status_changed 钩子在每次订单状态更改时通知某人,如下例所示:
add_action('woocommerce_order_status_changed', 'send_custom_email_notifications', 10, 4 );
function send_custom_email_notifications( $order_id, $old_status, $new_status, $order ){
$to_email = 'john.doe@gmail.com'; // <= Replace with your email custom field (the recipient)
$shop_name = __('Shop name'); // Set the shop name
$admin_email = 'shop@email.com'; // Set default admin email
$subject = sprintf( __('Order %s has changed to "%s" status'), $order_id, $new_status ); // The subject
$message = sprintf( __('Order %s has changed to "%s" status'), $order_id, $new_status ); // Message content
$headers = sprintf( __('From: %s <%s>'), $shop_name, $admin_email ) . "\r\n"; // From admin email
wp_mail( $to_email, $subject, $message, $headers ); // Send the email
}
代码在您的活动子主题(或活动主题)的functions.php 文件中。经过测试和工作
【讨论】:
woocommerce_add_to_cart_validation)。是否有插件允许使用 ajax 调用来完成此验证以避免页面刷新?我无法找到如何搜索它,或者可能我必须自己做?也许您已经回答了这样的问题?我非常确信这样的事情已经存在..