javascript Magento 单页结账上的“下订单”按钮没有响应。(内联 JS 未执行。)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7517391/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 00:23:04  来源:igfitidea点击:

"Place Order" button on Magento onepage checkout isn't responding. (Inline JS not executing.)

javascriptmagento

提问by Ross Bearman

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

目前正在尝试在安装 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.

每个步骤都可以正常工作,直到最终订单框review not defined,当尝试触发review.save()OnClick 事件时,“下订单”按钮给出错误。

The following script should create this reviewobject. 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.

以下脚本应创建此review对象。它与按钮在同一个文件中,并在用户到达订单流程的最后一步时通过 AJAX 调用。如果我直接访问文件,则执行此代码并创建对象,只有当它被结帐页面拉入时才不会运行。

<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.

我似乎找不到其他人遇到过这个问题,这段代码的每个版本(来自各种不同的模块)都以这种方式进行,所以我不确定为什么没有执行这个 JS。

Does anyone have any ideas?

有没有人有任何想法?

采纳答案by fxchain

Is this an upgrade? If so, try this: http://sree.cc/magento_ecommerce_tips/checkout-not-working-on-magento-version-1-4-xTry even if it's not an upgrade. I fixed that exact same issue several times with this solution.

这是升级吗?如果是这样,试试这个:http: //sree.cc/magento_ecommerce_tips/checkout-not-working-on-magento-version-1-4-x 即使不是升级也试试。我用这个解决方案多次修复了完全相同的问题。

I would do a diff. with a software like WinMerge. Check the differences on your checkout design folders, and the base Magento one.

我会做一个差异。使用像 WinMerge 这样的软件。检查结帐设计文件夹和基本 Magento 文件夹上的差异。

app/design/frontend/base/default/template/checkout vs. app/design/frontend/default/YOUR_THEME/template/checkout

app/design/frontend/base/default/template/checkout vs. app/design/frontend/default/YOUR_THEME/template/checkout

also check the XML file: app/design/frontend/base/default/layout/checkout.xml vs. app/design/frontend/default/YOUR_THEME/layout/checkout.xml

还要检查 XML 文件:app/design/frontend/base/default/layout/checkout.xml vs. app/design/frontend/default/YOUR_THEME/layout/checkout.xml

Hope this helps.

希望这可以帮助。

Francois

弗朗索瓦

回答by David Ung

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

我们正在迁移到更新的 Magento 版本 (1.8),“下订单”按钮对我们也不起作用。

Mukesh's answerpointed 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'));    

回答by Randhir Yadav

In app/design/frontend/mypackage/mytheme/template/checkout/onepage/review/info.phtml, I replaced & working grt.

在 app/design/frontend/mypackage/mytheme/template/checkout/onepage/review/info.phtml 中,我替换了 & 工作 grt。

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

with

<button type="submit" title="<?php echo $this->__('Place Order') ?>" class="button btn-checkout" onclick="review.save();"><span><span><?php echo $this->__('Place Order') ?></span></span></button>

回答by Mukesh

I Got solution of the same Issue by followwing code, May this will help you.

我通过以下代码获得了相同问题的解决方案,这可能会对您有所帮助。

Replace the base file the following path app/design/frontend/default/your_theme/template/checkout/onepage/review/info.phtml (or)

将基本文件替换为以下路径 app/design/frontend/default/your_theme/template/checkout/onepage/review/info.phtml (或)

Replace the line number 81 in info.phtml

替换 info.phtml 中的第 81 行

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

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