I'm trying to save some dates to the order when the order is placed. After checking out on the onepage checkout it just sits there. I receive the New Order email but it never redirects the browser to the success page. I have the additional date columns on the sales_order table and I can see the dates being saved to the table. I have tried removing all code from saveDates() except for return $this; and it still happens.
However, if I remove the event/observer from my config.xml everything works. After the order is placed, I get the New Order email and my browser is redirected to the success page. I just don't have the data saved to the order like I want.
I'm not sure why it's doing this. I find it really odd I can have my method do absolutely nothing and I won't be redirected. I have to remove the entire call to the observer from the XML before it will work normally. I don't know what's causing the checkout to not redirect.
config.xml
... <events> <sales_model_service_quote_submit_success> <observers> <namespace_module_observer> <class>namespace_module/observer</class> <method>saveDates</method> </namespace_module_observer> </observers> </sales_model_service_quote_submit_success> </events> ...
Observer.php
<?php class Namespace_Module_Model_Observer { public function saveDates(Varien_Event_Observer $observer) { /** @var Mage_Sales_Model_Order $order */ $order = $observer->getEvent()->getData('order'); if($order->getStoreId() == 1) { $order->setMyDate(date()); $order->save(); } return $this; } }
Solved! Go to Solution.
Wow, so I found the problem. My Observer.php looked like this. Notice the "c" before the opening php tag ... so the file was technically valid. But when it generated the JSON it spit out a c before anything else. This caused the JS to fail and not redirect to the success page. Such a stupid little error.
c<?php class Namespace_Module_Model_Observer { public function saveDates(Varien_Event_Observer $observer) { /** @var Mage_Sales_Model_Order $order */ $order = $observer->getEvent()->getData('order'); if($order->getStoreId() == 1) { $order->setMyDate(date()); $order->save(); } return $this; } }
Wow, so I found the problem. My Observer.php looked like this. Notice the "c" before the opening php tag ... so the file was technically valid. But when it generated the JSON it spit out a c before anything else. This caused the JS to fail and not redirect to the success page. Such a stupid little error.
c<?php class Namespace_Module_Model_Observer { public function saveDates(Varien_Event_Observer $observer) { /** @var Mage_Sales_Model_Order $order */ $order = $observer->getEvent()->getData('order'); if($order->getStoreId() == 1) { $order->setMyDate(date()); $order->save(); } return $this; } }