我在结帐中有一些代码,我在会话中设置了一个键,如果该键在结帐中的任何地方设置为 false,我需要将它们发送回计费页面。我有它的代码,但我也没有任何通常在观察者之后运行的代码,因为它会调用第三方服务并返回错误,因为会话中缺少这个键
这是我的代码,我拥有我想要的一切,但我需要立即发生响应,并且在调度的事件行之后只触发发送回浏览器的响应。
public function checkForOrdKey(Varien_Event_Observer $observer)
{
$controllerAction = $observer->getControllerAction();
$request = $controllerAction->getRequest();
$controllerName = $request->getControllerName();
$stepData = $this->_getCheckoutSession()->getStepData();
$ordKeyRemoved = $this->_getCheckoutSession()->getOrdKeyRemoved();
// if it is the checkout onepage controller or inventory controller don't do anything
if (isset($controllerName) && $controllerName === "onepage" && $stepData['shipping']['complete'] && $ordKeyRemoved) {
$this->_getCheckoutSession()->setStepData('shipping', 'complete', false);
$result['goto_section'] = 'billing';
Mage::app()->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
$this->_getCheckoutSession()->setOrdKeyRemoved(false);
}
}