结帐开始观察员 [英] Observer for Checkout Start

查看:76
本文介绍了结帐开始观察员的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Magento中是否有观察员来检测结帐过程的开始?这将包括点击页面checkout/onepage/checkout/onestepcheckout/.我想尽可能避免覆盖控制器.

Is there an observer in Magento to detect the start of the checkout process? This would include hitting the page checkout/onepage/ or checkout/onestepcheckout/. I would like to avoid overriding controllers if possible.

推荐答案

每个控制器动作都会导致多个目标事件,这些事件在

Every controller action will result in multiple targeted events which are fired in Mage_Core_Controller_Varien_Action (link), the superclass for all action controllers. These events variously involve the "full action name," derived from module router configuration + controller path + action, as well as the route name which is being requested.

在标准一页结帐的情况下,完整操作名称为checkout_onepage_index,路由名称为checkout_onepage.

In the case of standard onepage checkout, the full action name is checkout_onepage_index and the route name is checkout_onepage.

renderLayout():

controller_action_layout_render_before_'.$this->getFullActionName()

preDispatch():

controller_action_predispatch_' . $this->getRequest()->getRouteName() controller_action_predispatch_' . $this->getFullActionName()

postDispatch():

controller_action_postdispatch_' . $this->getRequest()->getRouteName() controller_action_postdispatch_' . $this->getFullActionName()

您观察到的事件将取决于OneStepCheckout模块如何捕获路由.如果需要区分路由和模块,则基于getRouteName()的事件可能会很有用.您将要测试客户已登录"和客户已注销"方案.虽然predispatch事件是涉及重定向的逻辑的首选,但是您将需要在您的需求与复制购物车/报价+客户会话逻辑之间取得平衡.

Which events you observe will depend on how the OneStepCheckout module captures routes. The getRouteName()-based events may be useful if you need to distinguish between routes and modules. You'll want to test "customer is logged in" and "customer is logged out" scenarios. While the predispatch events are preferred for logic which involves a redirect, you'll want to balance your needs against duplicating cart/quote + customer session logic.

这篇关于结帐开始观察员的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆