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
Tested & works.
Didn’t you save your changes?
You need to save the order changes with the save() function;