skilaq
skilaq

Reputation: 1

Automatically apply a status for new orders woocommerce

I want to update the status of any and all orders (paid or unpaid) to completed, triggering the emails from woocommerce. Sounds counter intuitive but it needs to happen.

I thought something like this would work:

add_action('woocommerce_order_status_changed','status_changed_processsing');
   function status_changed_processsing( $order_id, $checkout = null ) {
   global $woocommerce;
   $order = new WC_Order( $order_id );
       //assign statu to that order
       $order->status = 'completed';
    }

}

But I have not been successful.

TIA. Appreciate any help!

Upvotes: 0

Views: 71

Answers (2)

jjj
jjj

Reputation: 1005

Have a try with this one:

add_action( 'woocommerce_thankyou', 'status_changed_processsing' );
function status_changed_processsing( $order_id ) {
    $order = new WC_Order( $order_id );
    $order->update_status( 'completed' );
}

Upvotes: 1

mujuonly
mujuonly

Reputation: 11841

$order = new WC_Order($order_id);

if (!empty($order)) {
    $order->update_status( 'completed' );
}

try like this

Upvotes: 0

Related Questions