Magento在结账时跳过两步

时间:2013-01-04 11:29:44

标签: php magento magento-1.6

当访客用户已添加地址时,我必须从步骤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();
}

1 个答案:

答案 0 :(得分: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';