【问题标题】:Place Order fails in Magento OnePage Checkout在 Magento OnePage Checkout 中下订单失败
【发布时间】:2011-11-09 17:16:44
【问题描述】:

我有一家 Magento 商店,它已被转换为“一次交易”类型的商店,并且结帐流程已中断。我一直在尝试调试这个,但遇到了困难,主要是因为我对 Magento 的了解有限。

在saveOrder这一步,当点击“Place Order”时,页面显示“submitting order information, then message clears and the shopper is still in the Order Review page.

我用Firebug和HttpFox分析过,可以看到订单信息正在发送中

(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

发布数据显示所有必需的信息:

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

我的问题似乎与这篇文章类似: http://fishpig.co.uk/magento-tutorials/magento-checkout-error-undefined-javascript-alert

但我没有收到“未定义”警报,所以我在下面添加了“else”语句:

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');
        }
},

我收到没有文本的 JS 警报,所以它看起来像 transport.reponseText 是空的。我发现对空响应文本的主要引用似乎与同源策略有关,我认为这不适用,因为我的 AJAX 帖子往返于 www.domainname.com。

当我直接在浏览器中调用 saveOrder 函数时,我收到了一个有效的响应:

https://www.domainname.com/checkout/onepage/saveOrder {"success":false,"error":true,"error_messages":"信用卡号与信用卡类型不匹配"}

并且 HTTPFox 显示我从 Ajax 调用中获得了 200 响应,但响应文本只是空的。我在 Magento 的异常日志中没有发现 PHP 错误或错误。我发现唯一可能相关的是 Magento 系统日志中的“标头已发送”:

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

有没有人有任何建议,为什么 responseText 会空着回来?

【问题讨论】:

  • 你是在使用 print 语句在 php 中调试吗?这可能是 system.log 中“标头已发送”的原因之一。改用 Mage::log() 来调试进程 - magebase.com/magento-tutorials/… .
  • 我一直在使用 Mage::log,但是其他开发人员也在这个过程中工作,所以我会检查任何打印语句。
  • 等等,除了在标头之前发送的一些内容的问题之外,如果“信用卡号与信用卡类型不匹配”,您期望会发生什么?
  • 我之前调试过一个被覆盖的结帐过程,并注意到每当单页结帐无法进入该过程的下一步时,通常是自定义模块代码中的某些内容。因此,您可能会查看系统中任何自定义模块的代码,特别是覆盖结帐流程的代码。
  • 大卫,这就是问题所在。我最初排除了它,因为我认为禁用 Magento 管理员中的所有自定义模块实际上禁用了它们,而不是“禁用它们的输出”。不管什么意思。一旦我意识到这一点,我在模块配置中设置了 False 并且结帐工作。我能够解决自定义模块问题,所以我要结束这个问题。感谢 cmets。

标签: php ajax magento


【解决方案1】:

自定义模块有问题。在 Magento 管理员中禁用所有自定义模块实际上并没有禁用它们,它只是“禁用它们的输出”。

在模块配置中设置 False 解决了无效标头错误,此时我能够调试导致 AJAX 签出错误的自定义模块问题。

【讨论】:

  • 谢谢伙计!我遇到了同样的问题。如果您想结帐,我已经在这里解释了我的问题! wp.me/p38omN-5n
猜你喜欢
  • 1970-01-01
  • 2016-01-27
  • 2013-04-30
  • 2014-10-23
  • 2013-11-04
  • 1970-01-01
  • 1970-01-01
  • 2011-12-24
  • 1970-01-01
相关资源
最近更新 更多