I'm attempting to create a custom observer that will trigger after a successful purchase has been made. I assume that sales_order_save_after
is the correct event to use.
What the Observer will do is check to make sure the order is coming from the correct store, and then add some data into a new table. I thought I had done it correctly, but couldn't get it to work. After a bit of changing some things, I eventually glitched my test account I was making purchases on. It now receives this error whenever trying to checkout: Payment has already been made for this InvoiceID (#10412: Duplicate invoice)
Regardless, this is what I have:
Observer.php
<?php
class Namespace_Module_Model_Observer {
public function saveData(Varien_Event_Observer $observer) {
$order = $observer->getEvent()->getOrder();
$storeId = $order->getStoreId();
$incrementId = $order->getIncrementId();
$entity_id = $order->getEntityId();
if($storeId == 3){
// saving data via query
}
config.xml
<config>
<global>
<models>
<namespace>
<class>Namespace_Module_Model</class>
</namespace>
</models>
<events>
<sales_order_place_after>
<observers>
<namespace_module_savedata>
<class>Namespace_Module_Model_Observer</class>
<method>saveData</method>
<type>singleton</type>
</namespace_module_savedata>
</observers>
</sales_order_place_after>
</events>
</global>
</config>
Is everything here look correct? I just realized I had Namespace_Module_Model_Observer/observer
as the class before copying the code here. However, prior to that, I was still getting nothing for the most part. No errors/exceptions. I haven't tried adding an actual log dispatch to the observer yet though. Would that just be:
Mage::log($observer->getEvent()->getName(),null,'event.log');
?
/placeOrder/
, refresh takes back to cart with the error.