hideair

Untitled

Jun 27th, 2014
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.57 KB | None | 0 0
  1.    //Now Delete the Refund for an order but do not delete the order.
  2. $order = Mage::getModel('sales/order')->loadByIncrementId('XXX000320');
  3. //Delete Credit Memo
  4. $creditMemos = $order->getCreditmemosCollection();
  5. foreach($creditMemos as $cm){   //cancel each credit memo for the order
  6.     $state = $cm->getState();
  7.     if($state == 3){//Cancled
  8.         continue;
  9.     }
  10.     // you can also run an "if" check here on the CMs id for a specific CM
  11.     $cm->cancel()
  12.         ->save()
  13.         ->getOrder()->save();   //Needed to save the order to apply the canceled credit memo to all order items.
  14.  
  15.     $cm->delete();
  16. }
Advertisement
Add Comment
Please, Sign In to add comment