Emi*_*ugo 2 php wordpress status orders woocommerce
我想改变 每一个 订单 从与状态woocommerce “HOLD-ON” 为“处理” 用PHP。
我已经尝试在functions.php文件中编写一个函数,但是我失败了。
如何在 Woocommerce 中自动将订单状态从“保留”更改为“处理”?
要自动处理订单,您应该尝试以下操作:
add_action( 'woocommerce_thankyou', 'woocommerce_auto_processing_orders');
function woocommerce_auto_processing_orders( $order_id ) {
if ( ! $order_id )
return;
$order = wc_get_order( $order_id );
// If order is "on-hold" update status to "processing"
if( $order->has_status( 'on-hold' ) ) {
$order->update_status( 'processing' );
}
}
Run Code Online (Sandbox Code Playgroud)
代码位于活动子主题(或主题)的 function.php 文件中。