对于一个,您需要重写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');
}
然后是付款之后,通过事件观察器在其中保存订单的部分:
/**
* 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));
}
}
}
上述观察者方法暗含同意条款和条件。在某些国家/地区这是违法的,您可能需要显示条款并在“付款方式”页面上通过“同意过帐”字段。
另外,您可能想看看opcheckout.js,以确保人们不能两次发布订单。
这只是为您指明正确的方向。这不是一个完整的解决方案,因为确切的实现当然取决于客户的意愿,而我不想让您从中找出解决方案细节的乐趣。但是您完全陷入困境,请告诉我们。