Question

I'm tracking customer movements through the order process by using their QuoteId
Mage::helper('checkout/cart')->getQuote() - which is created as soon as a customer ads a product to the cart, however once an order is placed (eg on the sucess page) the QuoteId is no longer available (because the cart doesn't exist anymore) and an OrderId becomes available. Is it possible to get the QuoteId that was used to create the OrderId from the OrderId?

Was it helpful?

Solution

For the purpose of my question I was wanting to get the quoteId on the success page, with that in mind the quoteId is stored in the order object and can be accessed via the following

$order = Mage::getModel('sales/order')->loadByIncrementId(Mage::getSingleton('checkout/session')->getLastRealOrderId());
$quoteId = $order['quote_id'];

OTHER TIPS

I believe this is needless because a stored value on the order is quote_id. If you need to look up the order number from the quote, use the field reserved_order_id.

Regardless, if you still want to match up the quote id with the order increment id you would only have to override the class Mage_Sales_Model_Resource_Quote and the method getReservedOrderId as such:

public function getReservedOrderId($quote)
{
    return $quote->getId();
}

Again, I think this is a bad idea. It may have side effects that I have not considered.

At any rate, best of luck!

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top