1

I'm writing an extension. I hooked into event 'sales_order_place_before':

if (#condition) {  
    //redirect to cart
  $session = Mage::getSingleton('checkout/session');
  $session->addError(Mage::helper('checkout')->__('error'));
  Mage::app()->getFrontController()->getResponse()->setRedirect(Mage::getUrl('checkout/cart'));
  Mage::app()->getResponse()->sendResponse();
  exit;
}  

When using firefox, in Network -> Response tab, I get shopping cart page with above message. But checkout page actually stays the same and the number of items in inventory are decreased.

  • why have you using sales_place_order? – Amit Bera Feb 10 '15 at 3:51
  • because I needs to check #condition immediately after clicking Place Order button – Minh Chu Feb 10 '15 at 7:04
  • hi! When you say the "above message" which message is that, i dont quite understand, sorry – John Feb 14 '18 at 10:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.