2

I'm trying to implement an order confirmation module for guest accounts. I researched now for a couple hours but it seems that I can't find any solution to my problem.

I need to verify if the email of a guest customer is actually valid. After the order is placed I observe the sales_order_place_after event and try to set the guest order to holded or a custom one like unconfirmed. Either way the state change gets overwritten by Magento. After that I want to send an email with a verification link. And then change the state back to pending. I think I can overwrite the basic email template for a new guest order. Is this correct?

How can I set guest orders to a different state than the default "pending"?

Thank you all very much in advance!

1

Just observe the sales_order_save_before event, find a correct condition (this is important) how to determine, you change the status for the correct orders (not every time, an order is saved) and set the status

  • Hmm. I have the correct order but the state still gets overwritten. I have something like this: $order = Mage::getModel('sales/order')->loadByIncrementId($observer->event->order["increment_id"]); $order->setState(Mage_Sales_Model_Order::STATE_HOLDED, true); $order->save(); – M.K. Mar 13 '14 at 7:42
  • you need to get the order from the observer $observer->getOrder()->setState() – Fabian Blechschmidt Mar 13 '14 at 8:11
  • $observer->getOrder()->setState() gives me back the correct order of the observer instance. I can now change the state of the current order. But it only works if I observer the sales_order_place_after event. – M.K. Mar 13 '14 at 11:39
  • It should work in sales_order_save_before also. The problem is, that the status is changed after sales_order_place_after but should be changed before sales_order_save_before – Fabian Blechschmidt Mar 13 '14 at 11:51
  • I can set the status in both events. Say I set it to Mage_Sales_Model_Order::STATE_HOLDED. If I set in the event sales_order_save_before it changes but after the order is processed it's changed back to pending. In sales_order_place_after it's the exact opposite. Either way there will be two state changes. Is it event possible to just have on state set? But just in one case. I know that you can change the default status of a state. But I need this feature only for guest orders. – M.K. Mar 14 '14 at 12:17

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.