Magento – Order Confirmation Email

emailpayment

I have a small problem.
Basically I have two payment options on my site.
The one is C/Card which redirects to my providers site.
The second is a bank transfer method with no redirect.

So when using the bank transfer method it sends an order confirmation email to the customer.
but with c/card it does not.

I then changed the following code: /app/code/core/Mage/Checkout/Model/Type/Onepage.php

$redirectUrl = $this->getQuote()->getPayment()->getOrderPlaceRedirectUrl(); 
 /** 
  * we only want to send to customer about new order when there is no redirect to third party 
  */ 
 if (!$redirectUrl && $order->getCanSendNewEmailFlag()) { 
     try { 
         $order->sendNewOrderEmail(); 
     } catch (Exception $e) { 
         Mage::logException($e); 
     } 
 } 

to

$redirectUrl = $this->getQuote()->getPayment()->getOrderPlaceRedirectUrl(); 
 /** 
  * we only want to send to customer about new order when there is no redirect to third party 
  */ 
 if ($redirectUrl && $order->getCanSendNewEmailFlag()) { 
     try { 
         $order->sendNewOrderEmail(); 
     } catch (Exception $e) { 
         Mage::logException($e); 
     } 
 } 

This then switched the whole thing around so now the order confirmation email is sent only when I choose the c/card option with the re-direct and not when I chose the bank trf method.

My question: How do I get it to send the email for both payment options.

Best Answer

If you want the email to be sent in all the cases remove make the code look like this:

$redirectUrl = $this->getQuote()->getPayment()->getOrderPlaceRedirectUrl(); 
if ($order->getCanSendNewEmailFlag()) { 
    try { 
        $order->sendNewOrderEmail(); 
    } catch (Exception $e) { 
        Mage::logException($e); 
    } 
}

But I don't think it's a good idea. This way the customer will receive a confirmation of his order before he actually pays. A clean solution would be to leave the code as it originally was and for the credit card method send the e-mail when the payment confirmation comes back from the card processor.

Related Topic