How to send an email after a successful checkout?

In my store, I created a custom module for the one-step verification process.

All code is working fine. But a letter with a detailed description of the order is not sent to the client after the checkout process. Here is the relevant part of my code.

$service = Mage::getModel('sales/service_quote', $quote); $service->submitAll(); $order = $service->getOrder(); //This one is the email send code $order_mail = new Mage_Sales_Model_Order(); $incrementId = Mage::getSingleton('checkout/session')->getLastRealOrderId(); $order_mail->loadByIncrementId($incrementId); $order_mail->sendNewOrderEmail(); $this->_redirect('downloadable/customer/products/'); 
+4
source share
4 answers

try putting it in a try catch to see what the error is.

 <?php $order_mail = new Mage_Sales_Model_Order(); $incrementId = Mage::getSingleton('checkout/session')->getLastRealOrderId(); $order_mail->loadByIncrementId($incrementId); try { $order_mail->sendNewOrderEmail(); } catch (Exception $ex) { } ?> 
+1
source

To send / send order email to magento

 try { $incrementId = Mage::getSingleton('checkout/session')->getLastRealOrderId(); $_order = Mage::getModel('sales/order')->loadByIncrementId($incrementId); $_order->sendNewOrderEmail(); $this->_getSession()->addSuccess($this->__('The order email has been sent.')); } catch (Exception $e) { $this->_getSession()->addError($this->__('Failed to send the order email.')); Mage::logException($e); } 
+4
source

Have you debugged when it is sent to sendNewOrderEmail? Maybe this helps to find out where the problem is?

Hello

0
source

Try it,

  < ?php $order = new Mage_Sales_Model_Order(); $incrementId = Mage::getSingleton('checkout/session')->getLastRealOrderId(); $order->loadByIncrementId($incrementId); try { $order->sendNewOrderEmail(); } catch (Exception $ex) { } ?> 

Save the above snippet as .phtml and load it into app / code / core / Mage.

Now place an order on your website and check after successful verification. Email is sent or not. Hope your problem should be resolved now.

0
source

Source: https://habr.com/ru/post/1443420/


All Articles