Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Now Delete the Refund for an order but do not delete the order.
- $order = Mage::getModel('sales/order')->loadByIncrementId('XXX000320');
- //Delete Credit Memo
- $creditMemos = $order->getCreditmemosCollection();
- foreach($creditMemos as $cm){ //cancel each credit memo for the order
- $state = $cm->getState();
- if($state == 3){//Cancled
- continue;
- }
- // you can also run an "if" check here on the CMs id for a specific CM
- $cm->cancel()
- ->save()
- ->getOrder()->save(); //Needed to save the order to apply the canceled credit memo to all order items.
- $cm->delete();
- }
Advertisement
Add Comment
Please, Sign In to add comment