3
votes

I have a Magento store that has been converted to a "one deal at a time" type store, and the checkout process is broken. I've been trying to debug this, but have hit a wall, primarily due to my limited understanding of Magento.

On the saveOrder step, when clicking "Place Order", the page shows "submitting order information, then the message clears and the shopper is still on the Order Review page.

I've analyzed with Firebug and HttpFox, and I can see the order information is being sent

(Request-Line)  POST /checkout/onepage/saveOrder/ HTTP/1.1
Host    www.domainname.com
User-Agent  Mozilla/5.0 (Windows NT 6.0; rv:2.0) Gecko/20100101 Firefox/4.0
Accept  text/javascript, text/html, application/xml, text/xml, */*
Accept-Language en-us,en;q=0.5
Accept-Encoding gzip, deflate
Accept-Charset  ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive  115
Connection  keep-alive
X-Requested-With    XMLHttpRequest
X-Prototype-Version 1.6.0.3
Content-Type    application/x-www-form-urlencoded; charset=UTF-8
Referer https://www.domainname.com/checkout/onepage/
Content-Length  178
Cookie  frontend=cd60252d28cd115d4096cb2bb5b6a043
Pragma  no-cache
Cache-Control   no-cache

Post Data shows all of the required information:

payment[method] authorizenet
payment[cc_type]    VI
payment[cc_number]  4111111111111111
payment[cc_exp_month]   5
payment[cc_exp_year]    2012
payment[cc_cid] 987

My problem seemed similar to this post: http://fishpig.co.uk/magento-tutorials/magento-checkout-error-undefined-javascript-alert

but I'm not getting an "Undefined" alert, so I added the "else" statement below:

nextStep: function(transport){
    if (transport && transport.responseText) {
            alert(transport.responseText);
        try{
            response = eval('(' + transport.responseText + ')');
        }
        catch (e) {
            response = {};
        }
        if (response.redirect) {
            location.href = response.redirect;
            return;
        }
        if (response.success) {
            this.isSuccess = true;
            window.location=this.successUrl;
        }
        else{
            var msg = response.error_messages;
            if (typeof(msg)=='object') {
                msg = msg.join("\n");
            }
            alert(msg);
        }

        if (response.update_section) {
            $('checkout-'+response.update_section.name+'-load').update(response.update_section.html);
            response.update_section.html.evalScripts();
        }

        if (response.goto_section) {
            checkout.gotoSection(response.goto_section);
            checkout.reloadProgressBlock();
        }
    } else {
        alert('transport.responseText');
        }
},

I am getting the JS alert with no text, so it looks like transport.reponseText is empty. The main references to empty response text I've found appear to be related to same-origin policy, which I don't think applies, because my AJAX post is to and from www.domainname.com.

When I call the saveOrder function directly in the browser, I'm receiving a valid response:

https://www.domainname.com/checkout/onepage/saveOrder {"success":false,"error":true,"error_messages":"Credit card number mismatch with credit card type"}

and HTTPFox shows I'm getting a 200 response from the Ajax call, but the responsetext is simply empty. I find no PHP errors or errors in Magento's exceptions log. The only thing I'm finding that might be related is "Headers already sent' in Magento's system log:

</pre>
2011-09-03T12:14:21+00:00 DEBUG (7): HEADERS ALREADY SENT: <pre>[0] wwwroot/app/code/core/Mage/Core/Controller/Response/Http.php:50
[1] wwwroot/lib/Zend/Controller/Response/Abstract.php:726
[2] wwwroot/app/code/core/Mage/Core/Controller/Response/Http.php:82
[3] wwwroot/app/code/core/Mage/Core/Controller/Varien/Front.php:169
[4] wwwroot/app/Mage.php:459
[5] wwwroot/index.php:67
</pre>

Does anyone have any suggestions why else the responseText is coming back empty?

1
Are you using print statements to debug in php? That might be one cause for the 'Headers already sent' in system.log. Use Mage::log() instead to debug the process - magebase.com/magento-tutorials/… .arunkumar
I have been using Mage::log, but other developers worked on this process, so I'll check for any print statements.Canuteson
Wait, aside problem with some content sent before headers, what do you expect should happen if "Credit card number mismatch with credit card type"?Dmytro Zavalkin
I have debugged an overridden checkout process before and noticed that whenever the one page checkout fails to go to a next step in the process, it's usually something in custom module code. So you might look in the code of any custom modules in your system, specifically that overriding the checkout process.user439441
David, that was the problem. I had ruled it out originally, because I thought disabling all of the custom modules in the Magento admin actually disabled them, rather than "disabling their output". Whatever that means. Once I realize that, I set <Active>False</Active> in the module configuration and the checkout worked. I was able to resolve the custom module issues, so I'm closing this question. Thanks for the comments.Canuteson

1 Answers

1
votes

Custom modules were at fault. Disabling all of the custom modules in the Magento admin does not actually disable them, it only "disables their output".

Setting False in the module configuration resolved the invalid headers error, at which point I was able to debug the custom module issue that was causing the AJAX checkout errors.