【问题标题】:Magento skip two steps in checkoutMagento 在结帐时跳过两个步骤
【发布时间】:2013-01-04 11:29:43
【问题描述】:

当访客用户已经添加了地址时,我必须从第 1 步(选择结帐方式)转到送货方式步骤。我在方法 saveCheckoutMethod 中的覆盖类 Mage_Checkout_Model_Type_Onepage 中尝试了以下代码。但是,这不起作用,客人转到帐单地址步骤,但消息“设置步骤 shipping_method”。打印到 Magento 日志。有没有办法直接进入运输方式步骤并以编程方式跳过两个地址步骤?

public function saveCheckoutMethod($method)
{
    if (empty($method)) {
        return array('error' => -1, 'message' => $this->_helper->__('Invalid data.'));
    }

    $this->getQuote()->setCheckoutMethod($method)->save();

    $quote = $this->getQuote();
    if($quote->getBillingAddress()->validate() && $quote->getShippingAddress()->validate())
    {           
        $this->getCheckout()
            ->setStepData('billing', 'complete', false)
            ->setStepData('shipping', 'complete', false)
            ->setStepData('shipping_method', 'allow', true);
        Mage::log("Setting step shipping_method.");
    }
    else 
    {
        $this->getCheckout()->setStepData('billing', 'allow', true);
    }

    return array();
}

【问题讨论】:

标签: php magento magento-1.6


【解决方案1】:

你可以看看Mage_Checkout_OnepageController::saveBillingAction()方法,有一个例子你怎么能跳到另一个步骤(它跳过了送货地址步骤)

} elseif (isset($data['use_for_shipping']) && $data['use_for_shipping'] == 1) {
    // Here you can specify step name
    $result['goto_section'] = 'shipping_method';

    $result['update_section'] = array(
        'name' => 'shipping-method',
        'html' => $this->_getShippingMethodsHtml()
    );

    $result['allow_sections'] = array('shipping');
    $result['duplicateBillingInfo'] = 'true';

【讨论】:

  • 我试过了,但我似乎没有在方法 Mage_Checkout_OnepageController::saveMethodAction() 中工作,它进入下一步(账单地址)而不是送货方式。我已经通过将日志记录行添加到覆盖控制器来检查覆盖控制器是否实际运行。
猜你喜欢
  • 1970-01-01
  • 2012-08-26
  • 1970-01-01
  • 2018-06-15
  • 2018-03-17
  • 1970-01-01
  • 2013-08-03
  • 2018-04-08
  • 1970-01-01
相关资源
最近更新 更多