【发布时间】:2012-05-24 18:16:29
【问题描述】:
我只想知道一个属性是什么,当设置它时会将订单标记为失败,以便调用app/code/core/Mage/Checkout/controller/OnepageController.php 中的failureAction()。
我有一个 Observer.php,在其中我正在为成功付款和失败的付款保存订单创建发票,状态为 pending_payment,并希望将它们重定向到购物车页面,并在顶部显示错误消息。
这一切都很好。只是对于不成功/失败的付款,以及使用pending_payment状态保存订单n将它们重定向到带有错误消息的购物车页面,我还想保留/保存购物车以防变空。
但运气不好
Observer.php
public function implementOrderStatus($event)
{
$order = $event->getEvent()->getOrder();
if ($this->_getPaymentMethod($order) == 'mypaymentmodule')
{
$quote = Mage::getModel('sales/quote')->load($order->getQuoteId());
if($order->getPayment()->getCcTransId() == NULL)
{
$order->cancel();
$order->setStatus('canceled');
$order->save();
$quote->setIsActive(1)->save();
/*$state = 'pending_payment';
$status = 'pending_payment';
$comment = 'Payment transaction failed due to incorrect AVS/CVD details.';
$isNotified = false;
$order->setState($state,$status,$comment,$isNotified)->save();
$order->setCanSendNewEmailFlag(false);*/
Mage::getSingleton('checkout/session')->addError('Sorry, either of your card information (billing address or card validation digits) dint match. Please try again');
Mage::app()->getFrontController()->getResponse()->setRedirect('checkout/cart/')->sendResponse();
}
else
{
if ($order->canInvoice())
$this->_processOrderStatus($order);
}
}
return $this;
}
但$quote->setIsActive(true)->save() 似乎没有奏效。任何有关如何在将订单保存为“已取消”状态后避免我的购物车变空的帮助。
【问题讨论】: