I have added checkout_cart_product_add_after event in my custom module like :


And in Observer.php I want to get quote_id like :

public function customFunction(Varien_Event_Observer $observer)
    // here I want to get quote_id


How to get quote_id in customFunction?

  • have you got solution of it?? Feb 22, 2017 at 12:20
  • I don't know your purpose of the customFunction but if you observer the checkout_cart_product_add_after you will miss actions like updating the cart or removing a product.
    – Mr. Lewis
    Dec 3, 2018 at 14:40

3 Answers 3

public function customFunction(Varien_Event_Observer $observer){
      $quoteId = $observer->getQuoteItem()->getQuote()->getId();

You can get quote Id like this.

  • It is not working when first item added into quote, it is only working when quote already initiated and have at least one item in cart. Jan 30, 2017 at 6:33
  • What do you want to do in this function ? If you are use "checkout_cart_add_product_complete" observer instead of "checkout_cart_product_add_after" Jan 30, 2017 at 6:44
  • I am using both event in my custom module, in checkout_cart_product_add_after event, I want to set custom price to cart item. Jan 30, 2017 at 6:47

You can get Quote id using this code:

<?php $quote = $cart = Mage::getModel('checkout/cart')->getQuote(); 


You can get the quote id from checkout session like below:

$session        = Mage::getSingleton('checkout/session');
$quote_id       = $session->getQuoteId();

I hope this will help you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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