在 Magento 1.9 中单击“运输信息”部分中的“继续”按钮时,警报显示无效的运输方式

alert shows Invalid Shipping method while click continue button in Shipping Information section in Magento 1.9

removed the shipping method from checkout in magento.现在我有

 Billing Information, Shipping Information, Payment Information and Order Review sections 

only.When 我 click continue buttonShipping Information section 警告显示无效的送货方式

如果我在 Billing Information 中跳过 select 收音机的 Shipping Information section 作为 Ship to this address,它将转到付款信息部分。

Why the alert shows Invalid Shipping method while click continue button in Shipping Information section. 

我在 app\code\core\Mage\Checkout\controllers\OnepageController 中的 saveShippingAction() 函数是:

public function saveShippingAction()
    {
        if ($this->_expireAjax()) {
            return;
        }
        if ($this->getRequest()->isPost()) {
            $data = $this->getRequest()->getPost('shipping', array());
            $customerAddressId = $this->getRequest()->getPost('shipping_address_id', false);
            $result = $this->getOnepage()->saveShipping($data, $customerAddressId);

            if (!isset($result['error'])) {
                $method = 'freeshipping_freeshipping';
                $result = $this->getOnepage()->saveShippingMethod($method);

                if (!isset($result['error'])) {

                    $result['goto_section'] = 'payment';
                    $result['update_section'] = array(
                        'name' => 'payment-method',
                        'html' => $this->_getPaymentMethodsHtml()
                    );
                }
            }
            $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
        }
    }

我已经 disabled the flat rateenabled the free shipping 在后端 shipping method

编辑:在本地机器上这些工作正常,但在服务器上不工作。

在app/code/local/Mage/Checkout/Block/Onepage.php

Modify the line
    $stepCodes = array('billing', 'shipping', 'shipping_method', 'payment', 'review');

with
    $stepCodes = array('billing', 'shipping', 'payment', 'review');

在你的控制器中,我还会使用 $sectionUpdateFunctions

Change this section 
    protected $_sectionUpdateFunctions = array(
        'payment-method' => '_getPaymentMethodsHtml',
        'shpping-method' => '_getShippingMeghtoHtml',
        'review' => '_getReviewHtml',
    );

    protected $_sectionUpdateFunctions = array(
        'payment-method' => '_getPaymentMethodsHtml',
        'review' => '_getReviewHtml',
    );

这应该可以帮助您步入正轨。请不要编辑核心文件,这应该真正在您自己的模块中进行修改。但至少将其复制到显示的路径,以保持原始核心文件完好无损。这将使升级变得更加容易,并且只是最佳实践。

终于明白了!!

app\code\core\Mage\Checkout\Model\Type\Onepage.php中将代码改为

 public function saveShippingMethod($shippingMethod)
    {
        if (empty($shippingMethod)) {
           // return array('error' => -1, 'message' => Mage::helper('checkout')->__('Invalid shipping method.'));
           $shippingMethod = 'freeshipping_freeshipping'; 
        }
        $rate = $this->getQuote()->getShippingAddress()->getShippingRateByCode($shippingMethod);
        if (!$rate) {
            //return array('error' => -1, 'message' => Mage::helper('checkout')->__('Invalid shipping method.'));
            $shippingMethod = 'freeshipping_freeshipping'; 

更多信息:http://sapnandu-magento.blogspot.in/2012/04/magento-onestep-checkout-remove.html