0

The orders status gets updated to "closed" after I do a full refund for every order except for those paid using a gift card.I am able to manually set the order to "closed" using the following code:

$order->setData('state', 'complete');
$order->setStatus('complete');
$history = $order->addStatusHistoryComment('Manually set order to Complete.', false);
$history->setIsCustomerNotified(false);
$order->save();

This shows on the Magento Admin web too but right after, some event if triggered which sets the status back to "Completed". I use the following code to process a refund to giftcards:

$creditmemo = $serviceOrder->prepareInvoiceCreditmemo($invoice,$data);
        $creditmemo->setRefundRequested(true)
                ->setShippingAmount($order['shipping_amount'])
                ->setGrandTotal($order['grand_total'])
                ->setOfflineRequested(false)
                ->load()->refund();
$transaction = Mage::getModel('core/resource_transaction');
        $transaction->addObject($creditmemo)
                ->addObject($creditmemo->getOrder())
                ->addObject($creditmemo->getInvoice())
                ->save();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.