1

How can I make magento automatically email invoice/shipment after I create them.

what happens now is that:

1) I a create the invoice/shipment and then

2) I open the invoice/shipment and press send email.

I don't want to do the second step, I want the email to be send once the invoice/shipment created.

  • is this Magento behavior actually normal ?? or do I have some sort of a problem ?? – mubdea May 1 '16 at 20:43
  • Yes, you should be able to have emails send immediately once they are created, it's core behaviour. Which version are you running? If it's a recent version, do you have the Magento cron job configured and running correctly? – Robbie Averill May 1 '16 at 23:02
  • See this answer: stackoverflow.com/a/13285003/2812842 – Robbie Averill May 1 '16 at 23:08
  • I have magento 1.9.2.4. cron job is running without a problem – mubdea May 2 '16 at 11:54
2

you need to look at this magento event sales_order_shipment_save_after.

So in app/code/local/Namespace/Module/etc/config.xml:

...
<events>
    <sales_order_shipment_save_after>
    <observers>
        <namespace_module>
        <type>singleton</type>
        <class>Namespace_Module_Model_Observer</class>
        <method>autoEmail</method>
        </namespace_module>
    </observers>
    </sales_order_shipment_save_after>
</events>
....

and in app/code/local/Namespace/Module/Model/Observer.php:

    <?php
    class Namespace_Module_Model_Observer
    {
       public function autoEmail($observer) {
           $shipment = $observer->getEvent()->getShipment();
           $order = $shipment->getOrder();
// your email triggering code here.
       }
    }
1

I found the reason, it is a very silly mistake

when I create the invoice/shipment I don't click (Email Copy of invoice/Shipment).

I was thinking this will send a copy of the email to me, but when I tried it out. I found it is for sending a copy to the customer

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.