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

时间:2015-04-27 13:16:38

标签: php magento

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

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

。当我click continue button Shipping Information section 提示无效送货方式时。

如果我跳过Shipping Information section,请选择Ship to this address中的Billing Information广播,然后转到“付款信息”部分。

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

app \ code \ core \ Mage \ Checkout \ controllers \ OnepageController.php 中的 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 rate的后端已经enabled the free shippingshipping method

编辑:在本地计算机中,这些设备运行良好,但服务器无法正常工作。

2 个答案:

答案 0 :(得分:0)

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

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

答案 1 :(得分:0)

最后我明白了!

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