In Magento checkout page, during order review process, When place order button is clicked, it emits “Undefined” error in the form of javascript alert. I’ve been looking around for a fix for this error for long time and search in each and every file in my server inside checkout folder. Many developers had this issue and most of them pointed out that the issue is mainly due to custom modules or overriding of core modules, which is true by the way.

But How do I find the solution to this bug even though I know it is caused by overriding core modules in the checkout process. Yeah! It’s a very complicated process to find out the bug. I’ve found the bug by comparing each step in the checkout process with another store which is working perfectly. I’ve compared the issue store and perfectly working store with firebug console and found the bug in the ajax process.

Yes. “Undefined” Javascript alert is caused because some piece of s**t overrides core checkout modules without specifying form-key for order review section. It is located in the file info.phtml which is located in

app/design/frontend/default/YOUR_THEME/template/checkout/onepage/review

folder.  Open the info.phtml and go to the end of the file which has Review function in JS with 3 arguments. First 2 arguments were PHP codes and my issue is caused due to first argument i.e.,

 echo $this->getUrl('checkout/onepage/saveOrder');

But original file in the store i.e., file in the base folder has form-key for the above argument, like given below:

 echo $this->getUrl('checkout/onepage/saveOrder', array('form_key' => Mage::getSingleton('core/session')->getFormKey()));

Yes That’s right! There should be form key in hidden input field for the forms which uses POST method in Magento. If there isn’t form key, Form won’t be submitted in Magento. This is Golden Rule in Magento.