Reputation: 24635
When guest user has already added addresses, I have to move from step 1 (select checkout method) to shipping method step. I have tried following code in overrided class Mage_Checkout_Model_Type_Onepage in method saveCheckoutMethod. However this is not working, guest goes to Billing Address step, but message "Setting step shipping_method." is printed to Magento log. Is there any way to go directly to shipping method step and skip two address steps programmatically?
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();
}
Upvotes: 1
Views: 2815
Reputation: 3655
You can take a look at Mage_Checkout_OnepageController::saveBillingAction()
method, there is an example how can you jump to another step (it skips shipping address step)
} 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';
Upvotes: 1