Magento 2 checkout sessionWhich observer to use after success order on Magento 2?Magento model extension experiment, return: “class does not exist”Set custom price of product when adding to cart code not workingMagento 2 : Problem while adding custom button order view page?Magento 2: Add a product to the cart programmaticallyMagento 2.2.5: Overriding Admin Controller sales/order

Rent contract say that pets are not allowed. Possible repercussions if bringing the pet anyway?

How to maximize the drop odds of the Essences in Diablo II?

Can RMSE and MAE have the same value?

Filling a listlineplot with a texture

Ordering a list of integers

Is gzip atomic?

How to obtain a polynomial with these conditions?

Semantic difference between regular and irregular 'backen'

Changing JPEG to RAW to use on Lightroom?

Hangman game in Python - need feedback on the quality of code

Duplicate instruments in unison in an orchestra

Anyone else seeing white rings in the Undead parish?

Can $! cause race conditions when used in scripts running in parallel?

Evaluated vs. unevaluated Association

How to gently end involvement with an online community?

How many lines of code does the original TeX contain?

How much does Commander Data weigh?

Are the players on the same team as the DM?

Papers on arXiv solving the same problem at the same time

What do these commands specifically do?

Joining lists with same elements

Higman's lemma and a manuscript of Erdős and Rado

Movie where people enter a church but find they can't leave, not in English

Ghidra: Prepend memory segment in assembly listing view



Magento 2 checkout session


Which observer to use after success order on Magento 2?Magento model extension experiment, return: “class does not exist”Set custom price of product when adding to cart code not workingMagento 2 : Problem while adding custom button order view page?Magento 2: Add a product to the cart programmaticallyMagento 2.2.5: Overriding Admin Controller sales/order






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















Is there any way to store checkout custom field data to checkout session? If possible how can I retrieve data?



Created an event



<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="checkout_onepage_controller_success_action">
<observer name="checkout_onepage_observer" instance="MageplazaHelloWorldObserverTestObserver" />
</event>
</config>


Observer code-



 <?php
namespace OyeDeliverydateModelObserver;
use MagentoFrameworkEventObserver as EventObserver;
use MagentoFrameworkEventObserverInterface;

/**
* Class SaveDeliveryDateToOrderObserver
* @package OyeDeliverydateModelObserver
*/
class SaveDeliveryDateToOrderObserver implements ObserverInterface

/**
* @var MagentoFrameworkObjectManagerInterface
*/
protected $_objectManager;

/**
* @param MagentoFrameworkObjectManagerInterface $objectmanager
*/
public function __construct(MagentoFrameworkObjectManagerInterface $objectmanager)

$this->_objectManager = $objectmanager;


/**
* @param EventObserver $observer
* @return $this
*/
public function execute(EventObserver $observer)

$order = $observer->getOrder();
$quoteRepository = $this->_objectManager->create('MagentoQuoteModelQuoteRepository');
$quote = $quoteRepository->get($order->getQuoteId());
$order->setDeliveryDate( $quote->getDeliveryDate() );
//echo $quote->getDeliveryDate();
// exit();






In the observer last line I tried to echo deliverydate custom field value
using echo $quote->getDeliveryDate(); but not getting that value. Can I use session to store these custom checkout field value?










share|improve this question


























  • give more details at which location (model/controller/block) you are and what you try to save in session.

    – Hassan Ali Shahzad
    Oct 23 '18 at 7:29












  • If you have captche the custom field data at Magento checkout page then it is too tough to set save the data at session attribute

    – Amit Bera
    Oct 23 '18 at 8:02











  • Added More Details please check

    – Ragesh VP
    Oct 23 '18 at 8:42











  • $quote->getDeliveryDate() will not show anything unless you have saved Delivery Date in quote table.

    – Shashank Kumrawat
    Oct 23 '18 at 8:48











  • saved in quote table also

    – Ragesh VP
    Oct 23 '18 at 8:49

















0















Is there any way to store checkout custom field data to checkout session? If possible how can I retrieve data?



Created an event



<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="checkout_onepage_controller_success_action">
<observer name="checkout_onepage_observer" instance="MageplazaHelloWorldObserverTestObserver" />
</event>
</config>


Observer code-



 <?php
namespace OyeDeliverydateModelObserver;
use MagentoFrameworkEventObserver as EventObserver;
use MagentoFrameworkEventObserverInterface;

/**
* Class SaveDeliveryDateToOrderObserver
* @package OyeDeliverydateModelObserver
*/
class SaveDeliveryDateToOrderObserver implements ObserverInterface

/**
* @var MagentoFrameworkObjectManagerInterface
*/
protected $_objectManager;

/**
* @param MagentoFrameworkObjectManagerInterface $objectmanager
*/
public function __construct(MagentoFrameworkObjectManagerInterface $objectmanager)

$this->_objectManager = $objectmanager;


/**
* @param EventObserver $observer
* @return $this
*/
public function execute(EventObserver $observer)

$order = $observer->getOrder();
$quoteRepository = $this->_objectManager->create('MagentoQuoteModelQuoteRepository');
$quote = $quoteRepository->get($order->getQuoteId());
$order->setDeliveryDate( $quote->getDeliveryDate() );
//echo $quote->getDeliveryDate();
// exit();






In the observer last line I tried to echo deliverydate custom field value
using echo $quote->getDeliveryDate(); but not getting that value. Can I use session to store these custom checkout field value?










share|improve this question


























  • give more details at which location (model/controller/block) you are and what you try to save in session.

    – Hassan Ali Shahzad
    Oct 23 '18 at 7:29












  • If you have captche the custom field data at Magento checkout page then it is too tough to set save the data at session attribute

    – Amit Bera
    Oct 23 '18 at 8:02











  • Added More Details please check

    – Ragesh VP
    Oct 23 '18 at 8:42











  • $quote->getDeliveryDate() will not show anything unless you have saved Delivery Date in quote table.

    – Shashank Kumrawat
    Oct 23 '18 at 8:48











  • saved in quote table also

    – Ragesh VP
    Oct 23 '18 at 8:49













0












0








0








Is there any way to store checkout custom field data to checkout session? If possible how can I retrieve data?



Created an event



<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="checkout_onepage_controller_success_action">
<observer name="checkout_onepage_observer" instance="MageplazaHelloWorldObserverTestObserver" />
</event>
</config>


Observer code-



 <?php
namespace OyeDeliverydateModelObserver;
use MagentoFrameworkEventObserver as EventObserver;
use MagentoFrameworkEventObserverInterface;

/**
* Class SaveDeliveryDateToOrderObserver
* @package OyeDeliverydateModelObserver
*/
class SaveDeliveryDateToOrderObserver implements ObserverInterface

/**
* @var MagentoFrameworkObjectManagerInterface
*/
protected $_objectManager;

/**
* @param MagentoFrameworkObjectManagerInterface $objectmanager
*/
public function __construct(MagentoFrameworkObjectManagerInterface $objectmanager)

$this->_objectManager = $objectmanager;


/**
* @param EventObserver $observer
* @return $this
*/
public function execute(EventObserver $observer)

$order = $observer->getOrder();
$quoteRepository = $this->_objectManager->create('MagentoQuoteModelQuoteRepository');
$quote = $quoteRepository->get($order->getQuoteId());
$order->setDeliveryDate( $quote->getDeliveryDate() );
//echo $quote->getDeliveryDate();
// exit();






In the observer last line I tried to echo deliverydate custom field value
using echo $quote->getDeliveryDate(); but not getting that value. Can I use session to store these custom checkout field value?










share|improve this question
















Is there any way to store checkout custom field data to checkout session? If possible how can I retrieve data?



Created an event



<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="checkout_onepage_controller_success_action">
<observer name="checkout_onepage_observer" instance="MageplazaHelloWorldObserverTestObserver" />
</event>
</config>


Observer code-



 <?php
namespace OyeDeliverydateModelObserver;
use MagentoFrameworkEventObserver as EventObserver;
use MagentoFrameworkEventObserverInterface;

/**
* Class SaveDeliveryDateToOrderObserver
* @package OyeDeliverydateModelObserver
*/
class SaveDeliveryDateToOrderObserver implements ObserverInterface

/**
* @var MagentoFrameworkObjectManagerInterface
*/
protected $_objectManager;

/**
* @param MagentoFrameworkObjectManagerInterface $objectmanager
*/
public function __construct(MagentoFrameworkObjectManagerInterface $objectmanager)

$this->_objectManager = $objectmanager;


/**
* @param EventObserver $observer
* @return $this
*/
public function execute(EventObserver $observer)

$order = $observer->getOrder();
$quoteRepository = $this->_objectManager->create('MagentoQuoteModelQuoteRepository');
$quote = $quoteRepository->get($order->getQuoteId());
$order->setDeliveryDate( $quote->getDeliveryDate() );
//echo $quote->getDeliveryDate();
// exit();






In the observer last line I tried to echo deliverydate custom field value
using echo $quote->getDeliveryDate(); but not getting that value. Can I use session to store these custom checkout field value?







magento2 checkout session






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Oct 23 '18 at 8:47









Shashank Kumrawat

1,36613 silver badges47 bronze badges




1,36613 silver badges47 bronze badges










asked Oct 23 '18 at 7:19









Ragesh VPRagesh VP

86 bronze badges




86 bronze badges















  • give more details at which location (model/controller/block) you are and what you try to save in session.

    – Hassan Ali Shahzad
    Oct 23 '18 at 7:29












  • If you have captche the custom field data at Magento checkout page then it is too tough to set save the data at session attribute

    – Amit Bera
    Oct 23 '18 at 8:02











  • Added More Details please check

    – Ragesh VP
    Oct 23 '18 at 8:42











  • $quote->getDeliveryDate() will not show anything unless you have saved Delivery Date in quote table.

    – Shashank Kumrawat
    Oct 23 '18 at 8:48











  • saved in quote table also

    – Ragesh VP
    Oct 23 '18 at 8:49

















  • give more details at which location (model/controller/block) you are and what you try to save in session.

    – Hassan Ali Shahzad
    Oct 23 '18 at 7:29












  • If you have captche the custom field data at Magento checkout page then it is too tough to set save the data at session attribute

    – Amit Bera
    Oct 23 '18 at 8:02











  • Added More Details please check

    – Ragesh VP
    Oct 23 '18 at 8:42











  • $quote->getDeliveryDate() will not show anything unless you have saved Delivery Date in quote table.

    – Shashank Kumrawat
    Oct 23 '18 at 8:48











  • saved in quote table also

    – Ragesh VP
    Oct 23 '18 at 8:49
















give more details at which location (model/controller/block) you are and what you try to save in session.

– Hassan Ali Shahzad
Oct 23 '18 at 7:29






give more details at which location (model/controller/block) you are and what you try to save in session.

– Hassan Ali Shahzad
Oct 23 '18 at 7:29














If you have captche the custom field data at Magento checkout page then it is too tough to set save the data at session attribute

– Amit Bera
Oct 23 '18 at 8:02





If you have captche the custom field data at Magento checkout page then it is too tough to set save the data at session attribute

– Amit Bera
Oct 23 '18 at 8:02













Added More Details please check

– Ragesh VP
Oct 23 '18 at 8:42





Added More Details please check

– Ragesh VP
Oct 23 '18 at 8:42













$quote->getDeliveryDate() will not show anything unless you have saved Delivery Date in quote table.

– Shashank Kumrawat
Oct 23 '18 at 8:48





$quote->getDeliveryDate() will not show anything unless you have saved Delivery Date in quote table.

– Shashank Kumrawat
Oct 23 '18 at 8:48













saved in quote table also

– Ragesh VP
Oct 23 '18 at 8:49





saved in quote table also

– Ragesh VP
Oct 23 '18 at 8:49










2 Answers
2






active

oldest

votes


















0















To know about use of checkout session you should check below link -




http://blog.chapagain.com.np/magento-2-set-unset-get-session/




for more specific answer please share the exact event or requirement when you want to use checkout session.






share|improve this answer

























  • I added a custom field in magento 2 checkout page and data saved in quote table.How can I store these data in a custom table after checkout success??

    – Ragesh VP
    Oct 23 '18 at 7:29











  • you need to use any event observer in your module after order success like sales_order_place_after or checkout_submit_all_after and then there you can save value in your custom table.

    – Shashank Kumrawat
    Oct 23 '18 at 7:35











  • for your help check this link

    – Shashank Kumrawat
    Oct 23 '18 at 7:35


















0















protected $_checkoutSession;
public function __construct(
....
public function __construct(
MagentoCheckoutModelSession $checkoutSession
)

$this->_checkoutSession = $checkoutSession;


public function getCheckoutSession()

return $this->_checkoutSession;



You set a value :



$this->getCheckoutSession()->setVarValue('someValueHere');


You get a value :



$this->getCheckoutSession()->getVarValue(); //someValueHere


Then you unset the value :



$this->getCheckoutSession()->unsVarValue();





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%2f247446%2fmagento-2-checkout-session%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0















    To know about use of checkout session you should check below link -




    http://blog.chapagain.com.np/magento-2-set-unset-get-session/




    for more specific answer please share the exact event or requirement when you want to use checkout session.






    share|improve this answer

























    • I added a custom field in magento 2 checkout page and data saved in quote table.How can I store these data in a custom table after checkout success??

      – Ragesh VP
      Oct 23 '18 at 7:29











    • you need to use any event observer in your module after order success like sales_order_place_after or checkout_submit_all_after and then there you can save value in your custom table.

      – Shashank Kumrawat
      Oct 23 '18 at 7:35











    • for your help check this link

      – Shashank Kumrawat
      Oct 23 '18 at 7:35















    0















    To know about use of checkout session you should check below link -




    http://blog.chapagain.com.np/magento-2-set-unset-get-session/




    for more specific answer please share the exact event or requirement when you want to use checkout session.






    share|improve this answer

























    • I added a custom field in magento 2 checkout page and data saved in quote table.How can I store these data in a custom table after checkout success??

      – Ragesh VP
      Oct 23 '18 at 7:29











    • you need to use any event observer in your module after order success like sales_order_place_after or checkout_submit_all_after and then there you can save value in your custom table.

      – Shashank Kumrawat
      Oct 23 '18 at 7:35











    • for your help check this link

      – Shashank Kumrawat
      Oct 23 '18 at 7:35













    0














    0










    0









    To know about use of checkout session you should check below link -




    http://blog.chapagain.com.np/magento-2-set-unset-get-session/




    for more specific answer please share the exact event or requirement when you want to use checkout session.






    share|improve this answer













    To know about use of checkout session you should check below link -




    http://blog.chapagain.com.np/magento-2-set-unset-get-session/




    for more specific answer please share the exact event or requirement when you want to use checkout session.







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Oct 23 '18 at 7:24









    Shashank KumrawatShashank Kumrawat

    1,36613 silver badges47 bronze badges




    1,36613 silver badges47 bronze badges















    • I added a custom field in magento 2 checkout page and data saved in quote table.How can I store these data in a custom table after checkout success??

      – Ragesh VP
      Oct 23 '18 at 7:29











    • you need to use any event observer in your module after order success like sales_order_place_after or checkout_submit_all_after and then there you can save value in your custom table.

      – Shashank Kumrawat
      Oct 23 '18 at 7:35











    • for your help check this link

      – Shashank Kumrawat
      Oct 23 '18 at 7:35

















    • I added a custom field in magento 2 checkout page and data saved in quote table.How can I store these data in a custom table after checkout success??

      – Ragesh VP
      Oct 23 '18 at 7:29











    • you need to use any event observer in your module after order success like sales_order_place_after or checkout_submit_all_after and then there you can save value in your custom table.

      – Shashank Kumrawat
      Oct 23 '18 at 7:35











    • for your help check this link

      – Shashank Kumrawat
      Oct 23 '18 at 7:35
















    I added a custom field in magento 2 checkout page and data saved in quote table.How can I store these data in a custom table after checkout success??

    – Ragesh VP
    Oct 23 '18 at 7:29





    I added a custom field in magento 2 checkout page and data saved in quote table.How can I store these data in a custom table after checkout success??

    – Ragesh VP
    Oct 23 '18 at 7:29













    you need to use any event observer in your module after order success like sales_order_place_after or checkout_submit_all_after and then there you can save value in your custom table.

    – Shashank Kumrawat
    Oct 23 '18 at 7:35





    you need to use any event observer in your module after order success like sales_order_place_after or checkout_submit_all_after and then there you can save value in your custom table.

    – Shashank Kumrawat
    Oct 23 '18 at 7:35













    for your help check this link

    – Shashank Kumrawat
    Oct 23 '18 at 7:35





    for your help check this link

    – Shashank Kumrawat
    Oct 23 '18 at 7:35













    0















    protected $_checkoutSession;
    public function __construct(
    ....
    public function __construct(
    MagentoCheckoutModelSession $checkoutSession
    )

    $this->_checkoutSession = $checkoutSession;


    public function getCheckoutSession()

    return $this->_checkoutSession;



    You set a value :



    $this->getCheckoutSession()->setVarValue('someValueHere');


    You get a value :



    $this->getCheckoutSession()->getVarValue(); //someValueHere


    Then you unset the value :



    $this->getCheckoutSession()->unsVarValue();





    share|improve this answer





























      0















      protected $_checkoutSession;
      public function __construct(
      ....
      public function __construct(
      MagentoCheckoutModelSession $checkoutSession
      )

      $this->_checkoutSession = $checkoutSession;


      public function getCheckoutSession()

      return $this->_checkoutSession;



      You set a value :



      $this->getCheckoutSession()->setVarValue('someValueHere');


      You get a value :



      $this->getCheckoutSession()->getVarValue(); //someValueHere


      Then you unset the value :



      $this->getCheckoutSession()->unsVarValue();





      share|improve this answer



























        0














        0










        0









        protected $_checkoutSession;
        public function __construct(
        ....
        public function __construct(
        MagentoCheckoutModelSession $checkoutSession
        )

        $this->_checkoutSession = $checkoutSession;


        public function getCheckoutSession()

        return $this->_checkoutSession;



        You set a value :



        $this->getCheckoutSession()->setVarValue('someValueHere');


        You get a value :



        $this->getCheckoutSession()->getVarValue(); //someValueHere


        Then you unset the value :



        $this->getCheckoutSession()->unsVarValue();





        share|improve this answer













        protected $_checkoutSession;
        public function __construct(
        ....
        public function __construct(
        MagentoCheckoutModelSession $checkoutSession
        )

        $this->_checkoutSession = $checkoutSession;


        public function getCheckoutSession()

        return $this->_checkoutSession;



        You set a value :



        $this->getCheckoutSession()->setVarValue('someValueHere');


        You get a value :



        $this->getCheckoutSession()->getVarValue(); //someValueHere


        Then you unset the value :



        $this->getCheckoutSession()->unsVarValue();






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Oct 23 '18 at 8:03









        PЯINCƏPЯINCƏ

        8,7123 gold badges11 silver badges50 bronze badges




        8,7123 gold badges11 silver badges50 bronze badges






























            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.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f247446%2fmagento-2-checkout-session%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

            Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

            Circuit construction for execution of conditional statements using least significant bitHow are two different registers being used as “control”?How exactly is the stated composite state of the two registers being produced using the $R_zz$ controlled rotations?Efficiently performing controlled rotations in HHLWould this quantum algorithm implementation work?How to prepare a superposed states of odd integers from $1$ to $sqrtN$?Why is this implementation of the order finding algorithm not working?Circuit construction for Hamiltonian simulationHow can I invert the least significant bit of a certain term of a superposed state?Implementing an oracleImplementing a controlled sum operation

            Magento 2 “No Payment Methods” in Admin New OrderHow to integrate Paypal Express Checkout with the Magento APIMagento 1.5 - Sales > Order > edit order and shipping methods disappearAuto Invoice Check/Money Order Payment methodAdd more simple payment methods?Shipping methods not showingWhat should I do to change payment methods if changing the configuration has no effects?1.9 - No Payment Methods showing upMy Payment Methods not Showing for downloadable/virtual product when checkout?Magento2 API to access internal payment methodHow to call an existing payment methods in the registration form?