Magento Checkout Error – Cannot Checkout, Agree to All Terms and Conditions

checkoutmagento-1.9programmingtemplateterms and conditions

Hi we recently saw this error on Magento 1.9.0.1. And no idea why. And especially where to look on how to debug.

T&C haas been enabled in backend. And 1 agreement was set (ID=1). It does not matter if we uncheck or check the agreement. The error is always.

Please agree to all the terms and conditions before placing the order

We see however that AJAX traffic is running and that this is server side related. Which makes it even more interesting.

The response is
{"success":false,"error":true,"error_messages":"Please agree to all the terms and conditions before placing the order."}

I see this message comes from $this->_getCheckoutSession()->addError($this->__('Please agree to all Terms and Conditions before placing the order.')); in OnepageController.php (function: overviewPostAction()) … there is a diff … but no idea why it is not succesfull. WHat I did see however is that it is submitted as name="agreement[<?php echo $_a->getId()?>]"and processed using $postedAgreements = array_keys($this->getRequest()->getPost('agreement', array()));

UPDATE: It seems the agreement variable is sent in POST as agreement[2]:1 but I don't think $this->getRequest()->getPost('agreement', array()) will then capture it's value.

Question: Is this a known error? and if yes is there a method to fix?

Appreciate any tips ;P

Best Answer

I too had the same problem. After some deep digging i made it to work. In opcheckout.js you can find the below code

          var params = Form.serialize(payment.form);
          if (this.agreementsForm) {
              params += '&'+Form.serialize(this.agreementsForm);
          }

"this.agreementsForm" returns agreement form value but during the Form.serialize(this.agreementsForm) i got the empty value.

So in checkout/onepage/review/info.phtml find this line

 review = new Review('<?php echo $this->getUrl('checkout/onepage/saveOrder', array('form_key' => Mage::getSingleton('core/session')->getFormKey())) ?>', '<?php echo $this->getUrl('checkout/onepage/success') ?>', $('checkout-agreements'));

and replace with

 review = new Review('<?php echo $this->getUrl('checkout/onepage/saveOrder', array('form_key' => Mage::getSingleton('core/session')->getFormKey())) ?>', '<?php echo $this->getUrl('checkout/onepage/success') ?>', 'checkout-agreements');
Related Topic