Magento 在 OnePage Checkout 上的奇怪重定向行为
我的 Magento 版本是 - 1.4.1.1
我遇到两个问题:
1)当我执行 Onepage 结帐的各个步骤(注册、计费、运输和付款选项卡)时,有时在此过程中我会被重定向到购物车页面。没有错误,没有异常,var/report 中没有生成报告。我不知道如何调试它。没有我可以查找的日志吗?
2) 在单击下订单(最后一步)后的同一 Onepage Checkout 流程中,有时它会重定向到购物车页面,发送一封电子邮件,说明订单失败并显示以下消息:
在此操作之前必须收集报价总数。
为了解决这个问题,我在文件 magento/app/code/core/Mage/Sales/Model/Quote.php
的 prepareRecurringPaymentProfiles
中评论了这一行,这解决了问题
throw new Exception("Quote totals must be collected before this operation.");
:不知道这两个问题是否相关。但我现在没有遇到第二个问题,但经常遇到第一个问题。可能是什么原因以及如何解决?
进一步更新 - 我检查了 firebug 跟踪,这是 500 内部服务器错误,有时会出现在一页结账的任何步骤中。我能够深入研究 onepagecontroller.php 中的 savebillingaction、saveshippingaction 函数,发现当 $this->getRequest()->isPost() 为空时会出现错误,如果它是 1 那么它会继续,然后转到下一步,否则它会重定向到购物车,不,我不知道为什么这不是 1,还是因为 ajax 无法发送帖子数据,但我检查了 XHR 请求,Ajax 每次都会发送帖子数据(使用 firebug 扩展检查)。有人可以告诉我接下来我可以做什么来排除故障吗?我在哪里可以找到这些 Ajax 调用? Shipping.phtml(任何step.phtml)底部都有JS,它是如何调用OnePagecontroller saveshippingaction函数的?
My Magento Verison is - 1.4.1.1
I am having two problems:
1) When I am going through various steps of Onepage checkout (registration, billing, shipping, and payment tabs), sometimes during this process I am redirected to the cart page. There is no error, no exception, no report gets generated in var/report. I dont know how to debug it. Aren’t there any logs I can look for?
2) In same Onepage Checkout process after clicking on place the order (last step) , some times it redirects to the cart page, sends an email saying that the order failed with the message:
Quote totals must be collected before this operation.
To resolve it I commented this line in prepareRecurringPaymentProfiles
in the file magento/app/code/core/Mage/Sales/Model/Quote.php
, which solved the problem:
throw new Exception("Quote totals must be collected before this operation.");
I dont know if these 2 problems are related or not. But I am not having the 2nd problem now but having 1st one quite frequent. What could be the reason and how to resolve it?
further update-I checked the firebug trace, It is 500 internal server error which comes sometimes in any of the step in one page checkout. I was able to dig down into savebillingaction, saveshippingaction functions in onepagecontroller.php and found that error comes when $this->getRequest()->isPost() is blank , If it is 1 then it goes ahead, and goes to the next step else it redirects to cart, No I dont know why this is not 1 or is it because ajax is not able to send post data but I checked XHR request, Ajax send the post data every time (checked with firebug extension). Can Someone tell me What I could do next to troubleshoot. Where I can look for these Ajax Calls?
Shipping.phtml (any step.phtml) has JS at the bottom , How does it call OnePagecontroller saveshippingaction function ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
由于是服务器内部错误,请尝试访问服务器的错误日志。会告诉你问题出在哪里。我在 1.7.0 中也遇到过同样的问题。在我的示例中,问题出在
/app/code/core/Mage/Usa/Model/Shipping/Carrier/Fedex.php
Since it's internal server error, try to access the error log of the server. Will tell you where is the problem. I' ve had the same problem in 1.7.0. In my example the problem was at
/app/code/core/Mage/Usa/Model/Shipping/Carrier/Fedex.php
对于其他遇到“必须在此操作之前收集报价总数”的人。错误,请检查您的 Apache 日志以了解 500 内部服务器错误的原因。如果是这样的:
..PHP 响应时间太长。通常是 onepage/checkout saveOrder 操作,因为它相当繁重,并且通常需要连接到第三方服务(支付网关、时事通讯服务,如 mailchimp 等)。这些对第三方服务的调用可能需要一段时间,具体取决于网络状态,并且可能是 PHP 超时的原因。
您可以从增加超时开始,但这不是一个好的永久解决方案,因为您想首先找出发生这种情况的原因。
New Relic 是一个监控这些调用的好工具(也是监控您的 Magento 商店的一个好工具)。
For anyone else coming across the "Quote totals must be collected before this operation." error, check your Apache logs for the reason of the 500 internal server error. If it's something like this:
..PHP is taking too long to respond. Usually its the onepage/checkout saveOrder action because it's quite heavy and often needs to connect to third party services (payment gateways, newsletter services like mailchimp, etc.). These calls to third party services can take a while, depending on the network state and might be the reason of PHP timing out.
You can start by increasing the timeout, but it's not a good permanent solution because you want to find out why this is happening in the first place.
New Relic is a good tool to monitor these calls (and a good tool to monitor your Magento store in general).
首先,注释错误消息几乎从来都不是解决问题的方法,因为您只是掩盖了一些可能对您的系统产生严重后果的问题。
确定这样的错误可能很困难,但首先要检查几个地方:
如果是其中一种情况,您应该检查这些更改是否存在错误。如果没有,请尝试打开网站的默认主题并再次查看。如果错误消失,则表明您使用的主题有问题。如果仍然出现,则问题出在代码中。
在后一种情况下,使用 Firebug 验证有问题的页面请求是否会导致 Magento 向前端发送回“重定向”命令。如果情况并非如此,则可能是某种 JS 错误,但更可能的是您最终在系统中的某个地方出现了无效数据,导致 Magento 在结账时卡住。
另外(只是想到这一点,还没有尝试过),尝试多地址结账。我记得,它使用常规页面帖子,甚至可能比 OnePage 结帐具有更有用的消息传递。请根据上述发现编辑您的帖子,以便我们可以提供更多帮助(如果这不起作用)。
希望有帮助!
Firstly, commenting an error message is almost never the way to solve a problem, as you are just covering up some issue that may have severe consequences for your system.
Nailing down errors like this can be hard, but there are a few places to look first:
If one of those is the case, you should review those changes for bugs. If not, try turning on the default theme for the site and checking out again. If the bug disappears, there is a problem with the theme that you are using. If it still appears, the problem is in code.
In that latter case, use Firebug to verify that the offending page requests result in Magento sending back "redirect" commands to the frontend. If that isn't the case, it may be some kind of JS error, but more likely you are ending up with invalid data in the system somewhere that causes Magento to choke during checkout.
Also (just thought of this, haven't tried it), try the multi-address checkout. As I recall, it uses regular page posts, and may even have more useful messaging than the OnePage checkout. Please edit your post with your findings from the above so that we can help more if that doesn't do it.
Hope that helps!
以防万一有人收到“在此操作之前必须收集报价总数”的信息。错误,并且这些解决方案都没有解决其特定问题,我会提到我的问题是这样的:
skin/frontend/base/default/js/opcheckout.js
There was a JS error unique到这个网站,它正在清除付款表格并阻止 JS 读取其内容。您使用的模块或主题会有所不同,但请检查以确保付款表单可以正确序列化。如果没有,那可能是你的问题。
Just in case someone gets the "Quote totals must be collected before this operation." error, and none of these solutions fixes their particular problem, I'll mention that mine was an issue with this:
skin/frontend/base/default/js/opcheckout.js
There was a JS error unique to this site which was clearing the Payment form and preventing JS from reading it's contents. The module or theme that you use will differ, but check to make sure that the payment form can serialize correctly. If not, then that could be your problem.
我的 Princessly 商店也遇到了同样的问题:
“正在提交订单信息...”需要大约 20 到 130 秒甚至更长的时间才能完成并重定向到支付网关,例如与 PayPal 一样,如果有的话,在点击下订单按钮后,一页结帐的最后一步。
如果没有通过,很可能是因为花费太长时间而超时,它将重定向返回购物车,给客户留下一个空的购物车和一个待处理的付款订单,或者,它将给出以下例外:
<块引用>
在此操作之前必须收集报价总数。
因为显然,有些事情超时了,脚本在收集报价总额之前就结束了(这只是我的理论),因此发送了付款交易失败提醒电子邮件。
经过12个小时的研究和调试,我终于找到了罪魁祸首和解决方案。
Magento 默认启用 RSS 库存和新订单通知,因此每次按下下订单(然后保存“销售/订单”资源)时,都会刷新缓存,以便发布 RSS。对于 Magento 来说,缓存清理可能非常耗时。因此解决方案很简单。只需禁用 RSS 通知即可保存“销售/订单”资源。
找到 /app/code/core/Mage/Rss/etc/config.xml 并找到此块:
只需删除或注释掉它并刷新 System => 中的 Magento 缓存即可缓存管理=>全选=>提交。
现在,我的商店只需 1 秒甚至更短的时间即可完成下订单并重定向到支付网关。
I had the very same problem on my store Princessly:
It takes about 20 to 130 seconds or even longer for "Submitting order information ..." to go through and redirect to the payment gateway such as PayPal, if at all, after clicking the Place Order button, last step of one page checkout.
If it doesn't go through, very probably because something timed out since it took too long, it will redirect back to shopping cart, leaving the customer an empty cart and a Pending Payment order, OR, it will give the exception of:
Since obviously, well, something timed out and the script ends before quote totals are collected (which is just my theory), thus sending the Payment Transaction Failed Reminder email.
After 12 hours of research and debug, I finally found the culprit and the solution.
Magento enables RSS stock and new order notification by default, so every time Place Order is pressed ('sales/order' resources are then saved), cache is refreshed so RSS will be published. Cache cleaning can be very time-expensive for Magento. Therefore the solution is simple. Just disable RSS notification for save of 'sales/order' resources.
Find /app/code/core/Mage/Rss/etc/config.xml and locate this block:
Simply remove or comment it out and refresh Magento cache in System => Cache Management => Select All => Submit.
Now it only takes 1 second or even less for my store to go through Place Order and redirect to payment gateway.