1

I have added checkout_cart_product_add_after event in my custom module like :

<checkout_cart_product_add_after>
    <observers>
        <custom_detect_product_changes>
            <type>singleton</type>
            <class>custom/observer</class>
            <method>customFunction</method>
        </custom_detect_product_changes>
    </observers>
</checkout_cart_product_add_after>

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?

2
  • have you got solution of it??
    – aton1004
    Feb 22 '17 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 '18 at 14:40
0
public function customFunction(Varien_Event_Observer $observer){
      $quoteId = $observer->getQuoteItem()->getQuote()->getId();
}

You can get quote Id like this.

3
  • 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 '17 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 '17 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 '17 at 6:47
0

You can get Quote id using this code:

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

?>
1
0

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, privacy policy and cookie policy

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