I am programatically doing an invoice refund, and I want to set the order status to closed after the refund has happened.
The refund works, but changing the order status doesn't.
I was kind of hoping that the refund code would set the status to Closed for me, but it doesn't, the status just stays at Processing after the refund.
Here's the refund code:
$service = Mage::getModel('sales/service_order', $order); $creditmemo = $service->prepareInvoiceCreditmemo($invoice); $creditmemo->register(); $creditmemo->save();
I have read that the Complete and Closed statuses shouldn't be set manually, but I do need the order status changed to closed.
Here's what I've tried, none worked for me.
$order->setData('state', Mage_Sales_Model_Order::STATE_CLOSED); $order->save();