3

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?

3

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'];
2

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!

  • The key was getting the quote_id from the order object. I think you misunderstood the purpose given the second part of your answer. Because an orderId isn't created until a checkout is successful there's no method to track a user adding or removing items from their cart using an orderId. So I was using the quoteId as a unique identifier to track user's cart movements. When they would checkout I needed the quoteId to match to their previous behaviour (and also the incrementId as a reference to match up to admin orders but that was already given). – James Aug 16 '13 at 5:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.