Created
August 14, 2017 21:06
-
-
Save igorhasse/9c00c5533b2e89fc41b959c3a91af5f1 to your computer and use it in GitHub Desktop.
How to remove review step in checkout
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function saveOrder($observer) | |
{ | |
/** @var $controllerAction Mage_Checkout_OnepageController */ | |
$controllerAction = $observer->getEvent()->getControllerAction(); | |
/** @var $response Mage_Core_Controller_Response_Http */ | |
$response = $controllerAction->getResponse(); | |
/** | |
* jsonDecode is used because the response of the XHR calls of onepage checkout is always formatted as a json | |
* string. jesonEncode is used after the response is manipulated. | |
*/ | |
$paymentResponse = Mage::helper('core')->jsonDecode($response->getBody()); | |
if (!isset($paymentResponse['error']) || !$paymentResponse['error']) { | |
/** | |
* If there were no payment errors, immediately forward to saving the order as if the user had confirmed it | |
* on the review page. | |
*/ | |
$controllerAction->getRequest()->setParam('form_key', Mage::getSingleton('core/session')->getFormKey()); | |
/** | |
* Implicitly agree with the terms and conditions by confirming the order | |
*/ | |
$controllerAction->getRequest()->setPost('agreement', array_flip(Mage::helper('checkout')->getRequiredAgreementIds())); | |
$controllerAction->saveOrderAction(); | |
/** | |
* jsonDecode is used because the response of the XHR calls of onepage checkout is always formatted as a json | |
* string. jesonEncode is used after the response is manipulated. | |
* | |
* $response has here become the response of the saveOrderAction() | |
*/ | |
$orderResponse = Mage::helper('core')->jsonDecode($response->getBody()); | |
if ($orderResponse['error'] === false && $orderResponse['success'] === true) { | |
/** | |
* Check for redirects here. If there are redirects than a module such as Adyen wants to redirect to a | |
* payment page instead of the success page after saving the order. | |
*/ | |
if (!isset($orderResponse['redirect']) || !$orderResponse['redirect']) { | |
$orderResponse['redirect'] = Mage::getUrl('*/*/success'); | |
} | |
$controllerAction->getResponse()->setBody(Mage::helper('core')->jsonEncode($orderResponse)); | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class [Company]_[NameModule]_Block_Checkout_Onepage extends Mage_Checkout_Block_Onepage | |
{ | |
protected function _getStepCodes() | |
{ | |
if ($this->getQuote()->isVirtual()) { | |
return array('login', 'billing', 'payment'); | |
} | |
return array('login', 'billing', 'shipping', 'shipping_method', 'payment'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment