Magento 1.7 – How to Copy Cart Items from One Quote to Another

cartmagento-1.7quote

i want to copy one quote (only cart items) to other quote (only items ).
Only want to copy cart products to other new quote.

Suppose: i have old quote,which id is 5,have 4 items

 i have another quote which id 77, have 1 item, i want to copy  4 items of quote id  5 to 
quote id  77.

I have try below blog;
Programmatically add items to cart and assign to guest user

Best Answer

Have a look at the merge() method in Mage_Sales_Model_Quote. I've never used it, but it should be something such as:

$quoteA = Mage::getModel('sales/quote')->load('5');
$quoteB = Mage::getModel('sales/quote')->load('77');

$quoteB->merge($quoteA);

// Also?
$quoteB->collectTotals()->save();

Zend_Debug::dump($quoteB->getAllItems());

// edit - I looked at what Magento does in the checkout session model, and it also calls collectTotals() and save(), so that's probably necessary as well.

Have a look also at Mage_Checkout_Model_Session