开发者

Magento Strange Redirect Behaviour on OnePage Checkout

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 operatio开发者_如何学编程n.

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 ?


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


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:

mod_fcgid: read data timeout in 40 seconds
Premature end of script headers: index.php
process 26126 graceful kill fail, sending SIGKILL

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


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:

  1. Did you install this system on a lower version and then upgrade? If so, how?
  2. Are you using any extensions that modify the sales/checkout portion of the site?
  3. Have you overridden any of the models concerned with this part of the site?
  4. Have you changed the JS or HTML for the checkout?

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!


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

var params = Form.serialize(payment.form);

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.


I had the very same problem on my store Princessly:

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

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

    Quote totals must be collected before this operation.

    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:

<sales_order_item_save_after>
    <observers>
        <notifystock>
            <class>rss/observer</class>
            <method>salesOrderItemSaveAfterNotifyStock</method>
        </notifystock>
    </observers>
</sales_order_item_save_after>
<sales_order_item_save_after>
    <observers>
        <ordernew>
            <class>rss/observer</class>
            <method>salesOrderItemSaveAfterOrderNew</method>
        </ordernew>
    </observers>
</sales_order_item_save_after>

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜