How to get quote_id in “checkout_cart_product_add_after” event












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?










share|improve this question














bumped to the homepage by Community 11 hours ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.















  • 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
















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?










share|improve this question














bumped to the homepage by Community 11 hours ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.















  • 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














1












1








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?










share|improve this question













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?







magento-1.9 quote






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jan 30 '17 at 5:52









Vinaya Maheshwari

1,16211846




1,16211846





bumped to the homepage by Community 11 hours ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







bumped to the homepage by Community 11 hours ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.














  • 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


















  • 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
















have you got solution of it??
– aton1004
Feb 22 '17 at 12:20




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




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










3 Answers
3






active

oldest

votes


















0














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


You can get quote Id like this.






share|improve this answer





















  • 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.
    – Vinaya Maheshwari
    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"
    – prathmeshb1
    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.
    – Vinaya Maheshwari
    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());

?>





share|improve this answer























  • I tried it, but it is not working.
    – Vinaya Maheshwari
    Jan 31 '17 at 7:30





















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.






share|improve this answer





















    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "479"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f156946%2fhow-to-get-quote-id-in-checkout-cart-product-add-after-event%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    3 Answers
    3






    active

    oldest

    votes








    3 Answers
    3






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














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


    You can get quote Id like this.






    share|improve this answer





















    • 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.
      – Vinaya Maheshwari
      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"
      – prathmeshb1
      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.
      – Vinaya Maheshwari
      Jan 30 '17 at 6:47
















    0














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


    You can get quote Id like this.






    share|improve this answer





















    • 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.
      – Vinaya Maheshwari
      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"
      – prathmeshb1
      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.
      – Vinaya Maheshwari
      Jan 30 '17 at 6:47














    0












    0








    0






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


    You can get quote Id like this.






    share|improve this answer












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


    You can get quote Id like this.







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Jan 30 '17 at 6:19









    prathmeshb1

    1244




    1244












    • 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.
      – Vinaya Maheshwari
      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"
      – prathmeshb1
      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.
      – Vinaya Maheshwari
      Jan 30 '17 at 6:47


















    • 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.
      – Vinaya Maheshwari
      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"
      – prathmeshb1
      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.
      – Vinaya Maheshwari
      Jan 30 '17 at 6:47
















    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.
    – Vinaya Maheshwari
    Jan 30 '17 at 6:33




    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.
    – Vinaya Maheshwari
    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"
    – prathmeshb1
    Jan 30 '17 at 6:44




    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"
    – prathmeshb1
    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.
    – Vinaya Maheshwari
    Jan 30 '17 at 6:47




    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.
    – Vinaya Maheshwari
    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());

    ?>





    share|improve this answer























    • I tried it, but it is not working.
      – Vinaya Maheshwari
      Jan 31 '17 at 7:30


















    0














    You can get Quote id using this code:



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

    ?>





    share|improve this answer























    • I tried it, but it is not working.
      – Vinaya Maheshwari
      Jan 31 '17 at 7:30
















    0












    0








    0






    You can get Quote id using this code:



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

    ?>





    share|improve this answer














    You can get Quote id using this code:



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

    ?>






    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Jan 30 '17 at 9:26

























    answered Jan 30 '17 at 9:20









    Arunendra

    6,05331641




    6,05331641












    • I tried it, but it is not working.
      – Vinaya Maheshwari
      Jan 31 '17 at 7:30




















    • I tried it, but it is not working.
      – Vinaya Maheshwari
      Jan 31 '17 at 7:30


















    I tried it, but it is not working.
    – Vinaya Maheshwari
    Jan 31 '17 at 7:30






    I tried it, but it is not working.
    – Vinaya Maheshwari
    Jan 31 '17 at 7:30













    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.






    share|improve this answer


























      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.






      share|improve this answer
























        0












        0








        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.






        share|improve this answer












        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.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 4 '18 at 6:18









        Hardik Shah

        88858




        88858






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Magento Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f156946%2fhow-to-get-quote-id-in-checkout-cart-product-add-after-event%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            1300-talet

            1300-talet

            Has there ever been an instance of an active nuclear power plant within or near a war zone?