>Skip Order Review step on Onepage Checkout

Skip Order Review step on Onepage Checkout

Now and then, shop owners just want their customers be able to process orders as fast as possible and omit some unnecessary, annoying and time-consuming steps. This topic demonstrates some solutions to omit Order Review step at Checkout page in Magento.

First of all, we need to rewrite  _getStepCodes() function configured in Mage_Checkout_Block_Onepage. Actually, this function is located in Mage_Checkout_Block_Onepage_Abstract but we can not rewrite Abstract class, so just put it directly in extending class from Mage_Checkout_Block_Onepage

protected function _getStepCodes()
    {
        if ($this->getQuote()->isVirtual()) {
                return array('login', 'billing', 'payment');
        }
        return array('login', 'billing', 'shipping', 'shipping_method', 'payment');
    }

On Onpage Checkout, once customers fill in all payment information and move to the next step, we can force this event to save Order and move to Checkout success page by using Event Observer. The Event which needs to be configured here is controller_action_postdispatch_checkout_onepage_savePayment.

config.xml file of the module will be as following:

<events>
      <controller_action_postdispatch_checkout_onepage_savePayment>
        <observers>
          <controller_action_postdispatch_checkout_onepage_savePayment_handler>
            <type>model</type>
            <class>skiporderreview/observer</class>
            <method>saveOrder</method>
            <args></args>
          </controller_action_postdispatch_checkout_onepage_savePayment_handler>
        </observers>
      </controller_action_postdispatch_checkout_onepage_savePayment>
    </events>

Observer model File has saveOrder()  function as following:

public function saveOrder(Varien_Event_Observer $observer)
    {
        $controllerAction = $observer->getEvent()->getControllerAction();
        $response = $controllerAction->getResponse();
        $paymentResponse = Mage::helper('core')->jsonDecode($response->getBody());
        if (!isset($paymentResponse['error']) || !$paymentResponse['error']) {
            $controllerAction->getRequest()->setParam('form_key', Mage::getSingleton('core/session')->getFormKey());
            $controllerAction->getRequest()->setPost('agreement', array_flip(Mage::helper('checkout')->getRequiredAgreementIds()));
            $controllerAction->saveOrderAction();
            $orderResponse = Mage::helper('core')->jsonDecode($response->getBody());
            if ($orderResponse['error'] === false && $orderResponse['success'] === true) {
                if (!isset($orderResponse['redirect']) || !$orderResponse['redirect']) {
                        $orderResponse['redirect'] = Mage::getUrl('*/*/success');
                }
                $controllerAction->getResponse()->setBody(Mage::helper('core')->jsonEncode($orderResponse));
            }
        }
    }

When customers finish Payment step, the next step will directly move to Checkout success Page.

< Previous Post
Next Post >