Keep Woocommerce order status as pending
P粉627136450
P粉627136450 2024-03-28 16:34:08
0
1
525

I don't want Woocommerce to automatically update the order status from "Paused" to "Completed". I would like it to remain "on hold" as we are sending replacement items and waiting for the original items to be returned to us. Basically, I want to set it to "on hold" even after the item has been shipped. Is there any way to achieve this?

I tried using the following code without success:

add_action( 'woocommerce_payment_complete', 'cancel_completed_status' );
   
function cancel_completed_status( $order_id ){
  $order = wc_get_order( $order_id );
  $items = $order->get_items(); 
  foreach ( $items as $item_id => $item ) {
    $product_id = $item->get_variation_id() ? $item->get_variation_id() : $item->get_product_id();
    
    if ( $order->has_status( 'on-hold' )) {
        $order->update_status( 'on-hold' );
        $order->save();
    }
  }
}

P粉627136450
P粉627136450

reply all(1)
P粉476547076
add_action('woocommerce_order_status_completed', 'completed_to_onhold');

function completed_to_onhold($order_id) {

    $order = new WC_Order($order_id);
    $order->update_status('on-hold');
}
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template