_expireAjax(); if ($this->getRequest()->isPost()) { $data = $this->getRequest()->getPost('billing', array()); $customerAddressId = $this->getRequest()->getPost('billing_address_id', false); $result = $this->getOnepage()->saveBilling($data, $customerAddressId); if (!isset($result['error'])) { if ($this->getOnepage()->getQuote()->isVirtual()) { $this->loadLayout('checkout_onepage_review'); $result['goto_section'] = 'review'; $result['update_section'] = array( 'name' => 'review', 'html' => $this->getLayout()->getBlock('root')->toHtml() ); } elseif (isset($data['use_for_shipping']) && $data['use_for_shipping'] == 1) { $this->saveShippingMethodAction(); $this->loadLayout('checkout_onepage_review'); $result['goto_section'] = 'review'; $result['update_section'] = array( 'name' => 'review', 'html' => $this->_getReviewHtml() ); $result['allow_sections'] = array('shipping','review'); $result['duplicateBillingInfo'] = 'true'; } else { $result['goto_section'] = 'shipping'; } } $this->getResponse()->setBody(Zend_Json::encode($result)); } } public function saveShippingAction() { $this->_expireAjax(); if ($this->getRequest()->isPost()) { $data = $this->getRequest()->getPost('shipping', array()); $customerAddressId = $this->getRequest()->getPost('shipping_address_id', false); $result = $this->getOnepage()->saveShipping($data, $customerAddressId); if (!isset($result['error'])) { $this->saveShippingMethodAction(); $this->loadLayout('checkout_onepage_review'); $result['goto_section'] = 'review'; $result['update_section'] = array( 'name' => 'review', 'html' => $this->_getReviewHtml() ); } $this->getResponse()->setBody(Zend_Json::encode($result)); } } public function saveShippingMethodAction() { $this->_expireAjax(); if ($this->getRequest()->isPost()) { $this->savePaymentAction(); $data = $this->getRequest()->getPost('shipping_method', 'flatrate_flatrate'); //Change to your Shipping Method $result = $this->getOnepage()->saveShippingMethod($data); $this->getResponse()->setBody(Zend_Json::encode($result)); } } public function savePaymentAction() { $this->_expireAjax(); if ($this->getRequest()->isPost()) { $data = $this->getRequest()->getPost('payment', array('method'=>'worldpay_cc')); //Change to your Payment Processor try { $result = $this->getOnepage()->savePayment($data); } catch (Mage_Payment_Exception $e) { if ($e->getFields()) { $result['fields'] = $e->getFields(); } $result['error'] = $e->getMessage(); } catch (Exception $e) { $result['error'] = $e->getMessage(); } $redirectUrl = $this->getOnePage()->getQuote()->getPayment()->getCheckoutRedirectUrl(); if ($redirectUrl) { $result['redirect'] = $redirectUrl; } $this->getResponse()->setBody(Zend_Json::encode($result)); } } }