0

since after each Paypal payment the order confirmation email is not sent, i wanted to "force" this to happen.

The easiest solution i found online was to edit the following if statement

    if (!$redirectUrl && $order->getCanSendNewEmailFlag()) {
        try {
            $order->sendNewOrderEmail();
        } catch (Exception $e) {
            Mage::logException($e);
        }
    }

on \app\code\core\Mage\Checkout\Model\Type\Onepage.php but this will send an email even before the payment has been made.

So the only solution i can think about is to call sendNewOrderEmail() on the success payment page after the Paypal payment has been made.

The piece of code i was thinking of adding was something like (as appears on \app\code\core\Mage\Paypal\Model\Ipn.php)

    if (!$this->_order->getEmailSent()) {
        $this->_order->sendNewOrderEmail();
    }

but i really don't know where to put it in order to be called after the payment has been completed successfully.

Hope someone can help, thanks

1

Instead of rewriting classes, I suggest hooking onto an event. The sales_order_place_after event is fired after an order is paid for and completely finalized. Detailed code references are available on various forums, including Magento StackExchange. Do the following..

  1. Create an observer to listen to sales_order_place_after. See Mage_Sales_Model_Order::place().

  2. Check the payment.

  3. If the payment is exactly what you're looking for, send out an email.

I always recommend hooking onto an event before rewriting anything. Of course, this approach is not possible if Magento doesn't fire an appropriate event.

| improve this answer | |
0

For Magento to send out emails when placing orders via Paypal you need to setup Instant Payment Notification in your Paypal: https://developer.paypal.com/webapps/developer/docs/classic/ipn/integration-guide/IPNIntro/

| improve this answer | |

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.