Regularly updating your Magento stores brings not only the newest features, but also provides security fixes, which is highly important for your Magento store’s safety. Not updating your Magento stores can result in not only a bad performance, but it makes your shop an easy target for hackers. That’s we always recommended store owners to keep their Magento stores up to date with new security patches and using MageComp Upgrade Service will help you to install latest Magento patch without zero data loss and zero downtime. Meanwhile upgrading one Magento store to Magento CE 1.9.3.x along with SUPEE-9767, we came across an issue of Checkout is not working due to Form Key Validation enabled from admin backend.
Go to System > Configuration > Advanced > Security > Enable Form Key Validation on Checkout
On checkout page, when we select any payment method, we are unable to move further to complete the checkout process or even it doesn’t display any error or response just because enable the form key feature but when we have disabled Form Key Validation at Checkout, the checkout process functions as expected.
1 |
<input name="form_key" type="hidden" value="xxxxxxxxxxxxxx" disabled="" autocomplete="off"> |
While working on the issue in developer console, we found that CSS is adding the disabled selector to the form_key. it means a form_key value is not getting submitted to checkout controller causing the controller to return null. That’s why we need to pass form_key to checkout controller using following line.
1 |
<input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" class="pay-formkey" /> |
To resolve the issue, need to add a small script to payment.phtml file available on below location.
app\design\frontend\[YOUR THEME]\template\checkout\onepage\payment.phtml
1 2 3 4 5 6 7 8 9 |
<script> jQuery(document).ready(function(){ jQuery('#shipping-method-buttons-container .button').click(function(e){ setTimeout(function(){ jQuery("#co-payment-form .pay-formkey").removeAttr('disabled'); }, 2000); }); }); </script> |
That’s it, now your form_key is passed to checkout controller each and every time you proceed to order product. So, what else needed for the store owner, if their store works smoothly without any issue.
Get in touch with us for more update and comment down below if you are looking for any help regarding this code.
Happy Fixing !