0

I want to add a new field to the billing information step of the one page checkout, then process the customers input in a handler responding to the checkout_submit_all_after_handler event.

I'm able to add the HTML to display my new field in the billing information step. If I use an observer responding to the controller_action_predispatch_checkout_onepage_saveBilling event, then I can get the data the customer added to the new field by using:

Mage::app()->getFrontController()->getRequest()->getPost()

However I want to process the customers input in response to the checkout_submit_all_after_handler as Magento has done some house keeping by this point, such as creating the customer. If I use the above code to get the post data in response to checkout_submit_all_after_handler, it only contains payment information data (which is what you'd expect as that's the last step in the checkout process).

How do I get the custom data the user filled out in an earlier step (billing information), but right at the end of the checkout process.

1

In order to get information on last stage of checkout you have to store it somewhere. Session object might be a good option for you. During controller_action_predispatch_checkout_onepage_saveBilling event assign your custom observer where you will prepopulate from the request object custom data:

$customField = Mage::app()->getFrontController()->getRequest()->getParam('custom_field')l
Mage::getSingleton('checkout/session')->setCustomField($customField);

Make sure to clean session object when you will get custom field at the checkout_submit_all_after event.

Hope it helps.

| improve this answer | |
  • I was already considering this solution. It seems a bit in elegant, relying on two events. But if there is no other way to persist the additional information in the billing step through to the end of checkout, then I'll probably end up having to do this. I've up-voted but haven't accepted in case a better solution is possible. Thanks. – Dom Jan 16 '16 at 8:42
  • @Dom you should consider the fact that you have to save state of something. Right? There are only DB or Session options available. You store in session in order for you to transfer state to next step where you will store into DB. – Max Pronko Jan 16 '16 at 11:51

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.