无法在Magento One Page Checkout中保存转发方法

时间:2011-07-07 14:20:46

标签: magento magento-1.5

我正在按照本网站上的说明为我的网站编写一个自定义的Magento 1.5.0.1单页结帐: http://inchoo.net/ecommerce/magento/magentos-onepage-checkout-in-a-nutshell/

总之,我按顺序调用这些函数:

$checkout = Mage::getSingleton(‘checkout/type_onepage’);
$checkout->saveCheckoutMethod(‘guest’);
$checkout->saveBilling($billingAddress, false);
$checkout->saveShipping($shippingAddress, false);
$checkout->saveShippingMethod(‘flatrate_flatrate’);
$checkout->savePayment(array(‘method’=>’checkmo’));
// Extra part not on the site but saw it in the original magento onpage checkout controller
$checkout->getQuote()->getPayment()->importData(array(‘method’=>’checkmo’));
//
$checkout->saveOrder();
// Extra part not on the site but saw it in the original magento onpage checkout controller
$checkout->getQuote()->save();
//

问题是,当首次运行代码时,未设置送货方法,我收到错误消息,说明未设置送货方式。但是,只需刷新页面即可完成订单。

一个解决方案是在使用saveShippingMethod设置送货方法后,检查它是否设置为:

Mage::getSingleton('checkout/type_onepage')->getQuote()->getShippingAddress()->getShippingMethod();

其中100%的时间不是,然后将其重定向到同一页面,在第二次运行时设置运输方法......

这似乎是一个如此愚蠢的magento bug!有关如何使用此重定向(即页面刷新)修复它的任何想法?

1 个答案:

答案 0 :(得分:0)

也许我对magento并不是非常专家,但我确信在创建订单时你必须使用setShippingMethod($method)而不是saveShippingMethod($method),你可以查看更多here