Javascript – “Place Order” button on Magento onepage checkout isn’t responding. (Inline JS not executing.)

javascriptmagento

Currently trying to get onepage checkout working properly on an installation of Magento 1.6.0.0.

Each step works fine until the final review order box, the Place Order button gives the error review not defined, when trying to fire the review.save() OnClick event.

The following script should create this review object. It's in the same file as the button, and is called via AJAX when the user reaches the final step of the order process. If I access the file directly, this code is executed and the object created, it's only when it's pulled in by the checkout page that it doesn't run.

<script type="text/javascript">
  //<![CDATA[
  review = new Review('http://example.org/checkout/onepage/saveOrder/', 'http://example.org/checkout/onepage/success/', $('checkout-agreements'));
  SageServer = new EbizmartsSagePaySuite.Checkout
  ({
     'checkout': checkout,
     'review': review,
     'payment': payment,
     'billing': billing,
     'accordion': accordion
  });
  //]]>
</script>

I can't seem to find anyone else who's encountered this problem, every version of this code (from various different modules) does it in this manner, so I'm not sure why this JS isn't being executed.

Does anyone have any ideas?

Best Answer

We were migrating to a newer Magento version (1.8), and the "Place Order" button was not working for us as well.

Mukesh's answer pointed me to the right direction. However, the posted code was not working.

This worked for me:

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