![](/img/trans.png)
[英]Send customer processing order email notification for on-hold Woocommerce orders
[英]Immediately set on-hold orders to processing in WooCommerce and send the processing email notification
我需要将所有进入“暂停”的 WooCommerce 订单设置为“处理”,并立即发送订单处理电子邮件。
我试过这个
function custom_woocommerce_auto_order( $order_id ) {
if ( ! $order_id ) {
return;
}
$order = wc_get_order( $order_id );
if( 'on-hold'== $order->get_status() ) {
$order->update_status( 'processing' );
}
}
add_action( 'woocommerce_thankyou', 'custom_woocommerce_auto_order' );
尽管状态发生了变化,但仍会发送“暂停”电子邮件通知,即使它应该只是“处理中”电子邮件通知。
有什么建议吗?
只要付款未完成,订单就会处于暂停状态。 要将某些付款方式的默认订单状态立即更改为处理(并跳过暂停状态)并发送处理电子邮件通知,您可以使用:
woocommerce_bacs_process_payment_order_status
过滤器钩子woocommerce_cheque_process_payment_order_status
过滤钩woocommerce_cod_process_payment_order_status
过滤钩所以你得到:
function filter_process_payment_order_status( $status, $order ) {
return 'processing';
}
add_filter( 'woocommerce_bacs_process_payment_order_status','filter_process_payment_order_status', 10, 2 );
add_filter( 'woocommerce_cheque_process_payment_order_status','filter_process_payment_order_status', 10, 2 );
add_filter( 'woocommerce_cod_process_payment_order_status', 'filter_process_payment_order_status', 10, 2 );
这些过滤器会导致状态更改为所需的状态。 电子邮件通知将基于此自动发送
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.