1

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.

1

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.

  • Hi, Thank you for your help. I would love to have the email send only after successful payment and once the customer has been been redirected from the card processor to the success page but could not get it right. Any tips on how to do this? – Farhaan Jun 18 '13 at 7:21
  • The payment method module should have an url where the payment status is sent. In that action you should check if the message you receive from the card processor says the payment is OK and if it is then you should send the e-mail. I can only give you theoretical advice, since the payment methods modules tend to be different in implementation. – Marius Jun 18 '13 at 7:30

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.