title: How to Cancel an Order and Restore Products into Cart without removing existing products in Cart
body: <p>I have a situation like this,</p>
  
  <p>I tried to place an order, gone to Payment Gateway i left that transaction like that.</p>
  
  <p>In my Magento that order status is Pending Payment, I have created a button in admin panel onclick of the button the following thing will happen.</p>
  
  <p>I want to restore those products into customer Cart with out removing any other products from there cart(if any).</p>
  
  <p>Please have look into my code.</p>
  
  <pre><code>      &lt;?php $order_id = 224;
        $_order = Mage::getModel('sales/order')-&gt;load($order_id);
        if (!$_order-&gt;isCanceled() &amp;&amp; !$_order-&gt;hasInvoices()) {
            $_order-&gt;cancel();
            $_order-&gt;addStatusToHistory(Mage_Sales_Model_Order::STATE_CANCELED, $message);
            $_order-&gt;save();
            $quote = Mage::getModel('sales/quote')-&gt;load($_order-&gt;getQuoteId());
            $session1 = Mage::getSingleton('checkout/session');
            if ($quote-&gt;getId()) {
               $quote-&gt;setIsActive(true)-&gt;save();
               $session1-&gt;setQuoteId($_order-&gt;getQuoteId());
            }
            Mage::getSingleton('core/session')-&gt;setFailureMsg('order_failed');
            Mage::getSingleton('checkout/session')-&gt;setFirstTimeChk('0');
        } ?&gt;
  </code></pre>
  
  <p>Because of this code if i have any products in my cart i'm going to loose those products from my cart.</p>
  
  <p>But my concern is without loosing any products from my cart i want to restore these products in Customer Cart.</p>
  
  <p>Any ideas ?</p>
  
  <p>How can i get it done ?</p>