php - magento onepage checkout, creating an error message and redirect -


i have hook in checkout process of magento, in observer: checkout_controller_onepage_save_shipping_method. observer action happens once user chooses shipping method in magento clicks "next" button save shipping method , continue through checkout process.

i have written code may tell user (depending on various factors such shopping cart items , state being shipped to) may not proceed checkout process , must call store instead special shipping instructions.

the regular redirect functions don't work inside onepage checkout because wrapped in ajax script, have tried following:

mage::getsingleton('core/session')->adderror('the shipping required 1 of products attempting order..');  $response1 = $observer->getresponse();   $url = mage::geturl('checkout/cart');  $response1->setredirect($url); 

and

mage::throwexception($this->__('the shipping required 1 of products attempting order requires special instructions, please call us.'));   $observer->getrequest()->setparam('return_url','http://www.google.com/');             exit; 

and

mage::app()->getfrontcontroller()->getresponse()->setredirect(mage::geturl('checkout/cart')); mage::app()->getresponse()->sendresponse(); exit; 

but none of these work. believe have override functions in onepagecontroller.php not know need update. appreciated. thanks!

i had same problem when trying create error message on onepage checkout process , after several tries cancel process , alert user error message (my goal in observer function).

my code:

$result['success'] = false; $result['error'] = true; $result['error_messages'] = implode(', ', $errors); $response = mage::app()->getresponse(); $response->setbody(mage::helper('core')->jsonencode($result)); $response->sendresponse();  exit; 

Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -