📅  最后修改于: 2022-03-11 14:58:37.186000             🧑  作者: Mango
add_action('woocommerce_order_status_changed', 'ts_auto_complete_by_payment_method');
function ts_auto_complete_by_payment_method($order_id)
{
if ( ! $order_id ) {
return;
}
global $product;
$order = wc_get_order( $order_id );
if ($order->data['status'] == 'on-hold') {
$payment_method=$order->get_payment_method();
if ($payment_method!="COD") // change payment method
{
$order->update_status( 'processing' );
}}}