2015-04-22 172 views
0

我对Magento是全新的,我们目前正在使用1.4版本。在OnePage结账的步骤是:Magento OnePage修改,需要跳过步骤

  • 验算方法(客户或登录)
  • 帐单信息
  • 航运信息
  • 配送信息
  • 付款信息
  • 订单检查

我想跳过发货信息。为此,我做了两件事: 1.更改(实际扩展)的核心Checkout类不包含#4 Delivery Information('shipping_information'), 2.在Controller中,调用saveShippingAction()内的Checkout类方法saveShippingMethodAction ()(因为用户永远不会提交装运方法),并且手动传递数据值。

一切正常,和步骤被跳过,但是里面结帐:: saveShippingMethodAction()有以下两行:

Mage::dispatchEvent('checkout_controller_onepage_save_shipping_method', array('request'=>$this->getRequest(), 'quote'=>$this->getOnepage()->getQuote())); 
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result)); 

的问题是在​​使用。实际请求不是shipping_method而是shipping,因此输出(即应传递给步骤#5的支付信息的HTML表单字符串)未加载,因此步骤#5为空。

我的第一个instict是如何模拟请求,但可能有一个“Magento方式”来做到这一点。任何人都可以告诉我可能是什么,或者我可以如何准备getRequest()或者getResponse(),就好像我已经提交了具体的表单一样?谢谢!

回答

0

我明白你想做什么,但我不明白你做了什么。

好的,我会在这里向你解释一些东西。如果你正在谈论magento默认的onepage结帐,而不是你正在谈论的东西送货信息它实际上是送货方式。

也被问的东西

Mage::dispatchEvent('checkout_controller_onepage_save_shipping_method', array('request'=>$this->getRequest(), 'quote'=>$this->getOnepage()->getQuote())); 
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result)); 

它实际上没有任何与您的代码,因为它是插入您的活动的地方,它像一个钩子。

现在真正的问题和解决方案。我还没有尝试过,但这应该工作。

如果你看到

应用程序/代码/核心/法师/结算/控制器/ OnepageController.php

file.You需要在此文件中的变化。首先将此控制器覆盖到您自己的模块,这是首选方式,但您也可以在核心文件中进行测试。

现在,在这个文件,你会看到两个功能

public function saveShippingAction() 
    { 
//This function saves the shipping information of customer 
    } 

public function saveShippingMethodAction() 
    { 
//this function saves the shipping method 
    } 

在第一个功能,你会看到这样

if (!isset($result['error'])) { 
       $result['goto_section'] = 'shipping_method'; 
       $result['update_section'] = array(
        'name' => 'shipping-method', 
        'html' => $this->_getShippingMethodsHtml() 
       ); 
      } 

这个重定向到出货的一些代码方法。如果您想通过运送方法步骤(在您的情况下送货信息),然后更换通过

if (!isset($result['error'])) { 
$result['goto_section'] = 'payment'; 
       $result['update_section'] = array(
        'name' => 'payment-method', 
        'html' => $this->_getPaymentMethodsHtml() 
       ); 
} 

这上面的代码将完成重定向部分来自控制器端删除现在显示从布局文件的送货方式块的块。就是这样。

希望这会有所帮助。