I'm setting up a custom controller to extend Mage_Core_Controller_Front_Action. If a user adds an item to the cart, I want to check the quote lifetime. If it is old enough, then the user should be given a new quote. Nothing needs to be done for younger quotes. This added functionality will help us work around an abandoned cart issue that the client is facing. We aren't worried about any orphaned quotes, we just want the old quote duplicated into a new one, giving us a brand new quoteId.
In the CartController.php, I can get the current quoteId and the items inside with:
$current_cart = Mage::getSingleton('checkout/session');
$quote_id= $current_cart->getQuoteId();
$old_items = $this->_getQuote()->getAllVisibleItems();
But I don't know how to check for the quote lifetime (i.e. current time minus the last quote update), nor do I now how to initialize a brand new quote. I know all of this is stored in the sales_flat_quote and sales_flat_quote_item tables, but I hoped Magento was capable of doing this without mucking about with dangerous SQL statements.
Any ideas?