Pour un, vous devez réécrire Mage_Checkout_Block_Onepage :: _ getStepCodes ():
/**
* Get checkout steps codes
*
* @return array
*/
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');
}
Ensuite, il y a la partie où vous souhaitez enregistrer votre commande après l'étape de paiement via un observateur d'événement:
/**
* THIS METHOD IMMEDIATELY FORWARDS TO THE SAVE ORDER ACTION AFTER THE PAYMENT METHOD ACTION
*
* Save the order after having saved the payment method
*
* @event controller_action_postdispatch_checkout_onepage_savePayment
*
* @param $observer Varien_Event_Observer
*/
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));
}
}
}
La méthode d'observation ci-dessus est implicitement en accord avec les termes et conditions. Ceci est illégal dans certains pays et vous souhaiterez peut-être afficher les conditions et transmettre les champs de publication d'accord sur la page du mode de paiement.
Aussi, vous voudrez peut-être jeter un œil à opcheckout.js pour faire en sorte que les gens ne puissent pas envoyer le bon de commande deux fois, etc.
C'est juste pour vous orienter dans la bonne direction. Ce n'est pas une solution complète car la mise en œuvre exacte dépend bien sûr des souhaits de votre client et je ne veux pas vous priver du plaisir de découvrir vous-même les détails de la solution. Mais si vous êtes totalement coincé, faites-le nous savoir.