更新时间:2023-11-21 17:41:16
要使此功能正常运行,您只需要一个小功能即可对所有订单进行处理"扫描.状态在初始"钩子上显示,并将此状态更新为已完成".
To get this working you just need a little function that will scan all orders with a "processing" status on the 'init' hook, and that will update this status to "completed".
这是代码:
function auto_update_orders_status_from_processing_to_completed(){
// Get all current "processing" customer orders
$processing_orders = wc_get_orders( $args = array(
'numberposts' => -1,
'post_status' => 'wc-processing',
) );
if(!empty($processing_orders))
foreach($processing_orders as $order)
$order->update_status( 'completed' );
}
add_action( 'init', 'auto_update_orders_status_from_processing_to_completed' );
此代码已经过测试并且可以正常工作.
This code is tested and works.
代码进入您的活动子主题(或主题)的function.php文件中.或在任何插件php文件中.
广告&更新
发送两次的电子邮件通知周围有一个小错误,在此处解决:
避免对某些自动完成的订单重复发送电子邮件通知
There is a little bug around email notifications sent twice that is solved in here:
Avoid repetitive emails notification on some auto completed orders