1

I want to stop magento sending new order email in some cases.

I want to know from the community how to debug and backtrace the function that really send the order email confirmation email.

I've this event :

<sales_order_place_after>
                <observers>
                    <xx_yy_Model_sales_observer>
                        <type>singleton</type>
                        <class>xx_yy_Model_Sales_Observer</class>
                        <method>save_order</method>
                    </xx_yy_Model_sales_observer>
                </observers>
            </sales_order_place_after>

And in my save_order function i do this :

try{
            $order->setEmailSent(1);
            $order->setStatus("holded");
            $order->save();
        }
        catch(exception $e){
            Mage::log('Non inoltra ordine', 1,'orders.log');
            Mage::log($e->getMessage(),1,'orders.log');
        }

But i still receive the new email order. I'm trying to debug core_email_template_mailer and core_email_template but seems that the email is not sent from there.

any help could be appreciated!!

2

I think you can try to create one more Observer method for event sales_order_place_before and move

$order->setEmailSent(1);

to that new Observer method

1

Magento does not use events to send emails for order confirmation.

The email is sent on order save, specifically in the method sendNewOrderEmail() which is defined in /app/code/core/Mage/Sales/Model/Order.php (assuming that there is not custom module that modify it).

There is a setting in the backend: system -> config > sales emails where you can disable them.

If you want another condition I would write a custom module to extend Mage_Sales_Model_Order and add my custom check there in an overwrite of sendNewOrderEmail().

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.