更新时间:2023-11-21 17:49:52
要使此工作正常运行,您只需要一个小功能即可扫描所有带有处理"命令的订单.'init' 钩子上的状态,并且会将此状态更新为已完成".
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 文件中.
建议和更新
电子邮件通知发送两次有一个小错误,在这里解决:
避免在某些自动完成的订单上重复发送电子邮件通知