Magento: How to combine/merge payment method and review step in one step

===========checkout.xml replace with ==========

<checkout_onepage_paymentmethod>

<!– Payment method block Start–>
<block type=”checkout/onepage_payment_methods” name=”root2″ output=”toHtml”

template=”checkout/onepage/payment/methods.phtml”>
<action

method=”setMethodFormTemplate”><method>purchaseorder</method><template>payment/form/purchaseorder.phtml

</template></action>
</block>
<!– Payment method block End–>

<!– Review method block Start–>
<block type=”checkout/onepage_review_info” name=”root1″ output=”toHtml”

template=”checkout/onepage/review/info.phtml”>
<action

method=”addItemRender”><type>default</type><block>checkout/cart_item_renderer</block><template>checkout

/onepage/review/item.phtml</template></action>
<action

method=”addItemRender”><type>grouped</type><block>checkout/cart_item_renderer_grouped</block><template>

checkout/onepage/review/item.phtml</template></action>
<action

method=”addItemRender”><type>configurable</type><block>checkout/cart_item_renderer_configurable</block>

<template>checkout/onepage/review/item.phtml</template></action>
<block type=”checkout/cart_totals” name=”checkout.onepage.review.info.totals” as=”totals”

template=”checkout/onepage/review/totals.phtml”/>
<block type=”core/text_list” name=”checkout.onepage.review.info.items.before”

as=”items_before” translate=”label”>
<label>Items Before</label>
</block>
<block type=”core/text_list” name=”checkout.onepage.review.info.items.after”

as=”items_after” translate=”label”>
<label>Items After</label>
</block>
<block type=”checkout/agreements” name=”checkout.onepage.agreements” as=”agreements”

template=”checkout/onepage/agreements.phtml”/>
<block type=”core/template” name=”checkout.onepage.review.button” as=”button”

template=”checkout/onepage/review/button.phtml”/>
</block>
<!– Review method block End–>
</checkout_onepage_paymentmethod>

=====Add this code in your moduele config file(Nik/Customcheckout/etc/config.xml)====

<global>
<blocks>
<checkout>
<rewrite>
<onepage>Nik_Customcheckout_Block_Checkout_Onepage</onepage>
</rewrite>
</checkout>
</blocks>
<models>
<customcheckout>
<class>Nik_Customcheckout_Model</class>
</customcheckout>
</models>
<events>
<controller_action_postdispatch_checkout_onepage_savePayment>
<observers>
<customcheckout>
<class>customcheckout/observer</class>
<method>saveOrder</method>
</customcheckout>
</observers>
</controller_action_postdispatch_checkout_onepage_savePayment>
</events>
</global>

============ Nik/Customcheckout/Block/Checkout/Onepage.php============
<?php
class Nik_Customcheckout_Block_Checkout_Onepage extends Mage_Checkout_Block_Onepage
{
protected function _getStepCodes()
{

/**
* Originally these were ‘login’, ‘billing’, ‘shipping’, ‘shipping_method’, ‘payment’, ‘review’
*
* Stripping steps here has an influence on the entire checkout. There are more instances of

the above list
* among which the opcheckout.js file. Changing only this method seems to do the trick though.
*/
if ($this->getQuote()->isVirtual()) {
return array(‘login’, ‘billing’, ‘payment’);
}
return array(‘login’,’billing’, ‘shipping’, ‘shipping_method’, ‘payment’);
}
}

=========== Nik/Customcheckout/Model/Observer.php =============

class Nik_Customcheckout_Model_Observer
{
public function saveOrder($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));
}
}
}
}

 

Enjoy 🙂

Advertisements