skip to Main Content

I’m currently having the problem that I need to reset an order in some case completely. For this I’m first refunding the payment without creating a complete refund via the method wc_refund_payment().

If this was successfull, I’m trying to reset the order. First I’m removing all order items:

$order = wc_get_order( xxxx );
$order->remove_order_items();

After this I wanted to set the total of the order to 0 but from here on all tries failed:

$order->set_total(null);

I still can see the total of my order which is really strange. So I’m looking now for a clean and good way to reset the done payment completely so that the order is like the same as before the payment? The only thing I want to keep are the notices at the right side.

I know that it sounds strange but this is part of my concept and I’ve found no other way doing this.

2

Answers


  1. update_post_meta($order_id,'_order_total', '0.00');
    

    Tested & works.

    Login or Signup to reply.
  2. Didn’t you save your changes?
    You need to save the order changes with the save() function;

    $order->save();
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search