3

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

1

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');
| improve this answer | |
1

No idea why, but .... moving the agreements block broke it all .... just been testing and re-testing this ...

this works

<div id="checkout-review-submit">
    <?php echo $this->getChildHtml('agreements') /** CUSTOM CODE SNH - DONT MOVE IT WILL BREAK **/?>
    <div class="buttons-set" id="review-buttons-container">
        <p class="f-left">

        <?php echo $this->__('Forgot an Item?') ?> <a href="<?php echo $this->getUrl('checkout/cart') ?>"><?php echo $this->__('Edit Your Cart') ?></a><br/>
        /p>

        <?php echo $this->getChildHtml('button') ?>

this does not

    <div id="checkout-review-submit">

        <div class="buttons-set" id="review-buttons-container">
            <p class="f-left">

            <?php echo $this->__('Forgot an Item?') ?> <a href="<?php echo $this->getUrl('checkout/cart') ?>"><?php echo $this->__('Edit Your Cart') ?></a><br/>
<?php echo $this->getChildHtml('agreements') /** CUSTOM CODE SNH - DONT MOVE IT WILL BREAK **/?>
            /p>

            <?php echo $this->getChildHtml('button') ?>
| improve this answer | |
  • Probably because getChildHtml() is nested within a particular block in the layout for that page and you're attempting to insert it into another block via the template, but not changing the layout to tell Magento its new parent block. If you read the layout for this particular area of the shopping cart, you can see where you can move the reference for the agreements block to be the child of the item where you want to insert it. See the following for an explanation of what getChildHtml() does in relation to layouts. – Fiasco Labs Jul 4 '15 at 4:08
  • Link with explanation of function => magento.stackexchange.com/questions/19370/… – Fiasco Labs Jul 4 '15 at 5:26
  • Thanks. The only difference though is that html is! outputted. Only it does not work. I will investigate. – snh_nl Jul 4 '15 at 5:50
  • The point was that getChildHtml() is connected to layout, you must move the block in layout as well as in the template. – Fiasco Labs Jul 4 '15 at 6:59
  • And you expect it to work then? Just questioning because the exact same html is outputted – snh_nl Jul 4 '15 at 7:01

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.