如何删除一页结帐中的“审阅”步骤?


12

我希望在“付款方式”步骤之后处理订单,省略Review“一页结帐”中的步骤。

是否有人对此有经验,或者可以向我指出正确的方法?

谢谢


2
仅供参考:在某些国家/地区这是非法的。
user487772 2013年

我将审核步骤更改为与付款有关,因此用户可以在一个阶段中进行审核和付款。有什么想法可以改变这个工作流程?
Eduardo Luz 2013年

我发现这是该过程的一个很好的解释:excellencemagentoblog.com/...
ryaan_anthony

Answers:


9

对于一个,您需要重写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,以确保人们不能两次发布订单。

这只是为您指明正确的方向。这不是一个完整的解决方案,因为确切的实现当然取决于客户的意愿,而我不想让您从中找出解决方案细节的乐趣。但是您完全陷入困境,请告诉我们。


如何创建观察服务器?
Akshay Taru 2015年

您可以编辑帖子以创建观察者吗?
Akshay Taru 2015年

写得很好-控制器扩展也可以做到这一点,方法是在调用之前刷新表单键saveOrderAction(),然后像在观察者方法中一样添加响应处理。
罗比·阿夫里尔

0

创建事件观察者:

<controller_action_postdispatch_checkout_onepage_savePayment> <observers> <Name_Event_Observer> <class>module/observer</class> <method>method</method> </Name_Event_Observer> </observers> </controller_action_postdispatch_checkout_onepage_savePayment>


By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.