服务报价 | 域名主机 | 网络营销 | 软件工具| [加入收藏]
 热线电话: #
当前位置: 主页 > php教程 > magento教程 >

Magento支付流程跳过运费步骤

时间:2016-05-08 10:32来源: 作者: 点击:
magento的支付流程大家总是觉得很麻烦的,总共有5步,最近在做一个项目,需要把运费的这两步跳过去,最终调整为3步,在网上找了点资料,整理如下, 1.修改app\code\core\Mage\Checkout\Blo
magento的支付流程大家总是觉得很麻烦的,总共有5步,最近在做一个项目,需要把运费的这两步跳过去,最终调整为3步,在网上找了点资料,整理如下,

 

1.修改app\code\core\Mage\Checkout\Block \Onepage.php 我们需要做的是修改默认的step,就是修改getStep function

01    public function getSteps()
02     {
03     $steps = array();
04     if (!$this->isCustomerLoggedIn()) {
05     $steps['login'] = $this->getCheckout()->getStepData('login');
06     }
07     //$stepCodes = array('billing', 'shipping', 'shipping_method', 'payment', 'review');
08     $stepCodes = array('billing', 'payment', 'review');
09     foreach ($stepCodes as $step) {
10     $steps[$step] = $this->getCheckout()->getStepData($step);
11     }
12     return $steps;
13     }

2.修改app\code\core\Mage\Checkout\controllers\ OnepageController.php 删除shipping的html输出并且控制saveBillingAction() 处理后的跳转

1    protected $_sectionUpdateFunctions = array(
2     'payment-method' => '_getPaymentMethodsHtml',
3     // 'shipping-method' => '_getShippingMethodsHtml',
4     'review' => '_getReviewHtml',
5     );
01    public function saveBillingAction()
02     {
03     if ($this->_expireAjax()) {
04     return;
05     }
06     if ($this->getRequest()->isPost()) {
07     //$postData = $this->getRequest()->getPost('billing', array());
08     //$data = $this->_filterPostData($postData);
09     $data = $this->getRequest()->getPost('billing', array());
10     $customerAddressId = $this->getRequest()->getPost('billing_address_id', false);
11     if (isset($data['email'])) {
12     $data['email'] = trim($data['email']);
13     }
14     $result = $this->getOnepage()->saveBilling($data, $customerAddressId);
15     if (!isset($result['error'])) {
16     /* check quote for virtual */
17     if ($this->getOnepage()->getQuote()->isVirtual()) {
18     $result['goto_section'] = 'payment';
19     $result['update_section'] = array(
20     'name' => 'payment-method',
21     'html' => $this->_getPaymentMethodsHtml()
22     );
23     }
24     /*elseif (isset($data['use_for_shipping']) && $data['use_for_shipping'] == 1) {
25     $result['goto_section'] = 'shipping_method';
26     $result['update_section'] = array(
27     'name' => 'shipping-method',
28     'html' => $this->_getShippingMethodsHtml()
29     );
30     $result['allow_sections'] = array('shipping');
31     $result['duplicateBillingInfo'] = 'true';
32     }*/
33     //End of Comment by Amit Bera
34     else {
35     //$result['goto_section'] = 'shipping';
36     $result['goto_section'] = 'payment';
37     }
38     }
39     $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
40     }
41     }

3.最后需要修改的是验证,如果不修改的话,会产品脚本验证的错误:app\code\core\Mage\Sales\Model\Service\ Quote.php

01    protected function _validate()
02     {
03     $helper = Mage::helper('sales');
04     if (!$this->getQuote()->isVirtual()) {
05     $address = $this->getQuote()->getShippingAddress();
06     $addressValidation = $address->validate();
07     // if ($addressValidation !== true) {
08     // Mage::throwException(
09     //$helper->__('Please check shipping address information. %s', implode(' ', $addressValidation))
10     //);
11     /

(责任编辑:最模板)
顶一下
(0)
0%
踩一下
(0)
0%
------分隔线----------------------------
栏目列表
热点内容