cancel
Showing results for 
Search instead for 
Did you mean: 

Magento2: automatically send email when shipment is created from invoice

Magento2: automatically send email when shipment is created from invoice

I'm wondering, how to automatically send Shipment information to the customer if Shipment is created from Invoice?

I have set checkbox "Notify customer by email" to enabled by default, but that not work when the shipment is created from Invoice, not separately.

4 REPLIES 4

Re: Magento2: automatically send email when shipment is created from invoice

You need to refer below blog for automatic shipment when invoice is generated,

https://www.mageplaza.com/magento-2-create-shipment-programmatically.html

 

You have to set after invoice is generated in your code.

If Issue Solved, Click Kudos/Accept As solutions. Get Magento insight from
Magento 2 Blogs/Tutorial

Re: Magento2: automatically send email when shipment is created from invoice

Hi, thanks for reply! I guess my problem slightly different - i do not need to create shipment automatically, but send notification to customer automatically when shipment is created (manually). 

Re: Magento2: automatically send email when shipment is created from invoice

You need to remove condition from file,

vendor/magento/module-sales/Controller/Adminhtml/Order/Invoice/Save.php

Just remove conditions from above file, 

if ($shipment) {
                try {
                 /* comment our below conditions */
                   /* if (!empty($data['send_email'])) { 
                        $this->shipmentSender->send($shipment);
                    } */
                  $this->shipmentSender->send($shipment);
                } catch (\Exception $e) {
                    $this->_objectManager->get(\Psr\Log\LoggerInterface::class)->critical($e);
                    $this->messageManager->addError(__('We can\'t send the shipment right now.'));
                }
            }

comment conditions and your mail is getting when shipment is generated. 

If Issue Solved, Click Kudos/Accept As solutions. Get Magento insight from
Magento 2 Blogs/Tutorial

Re: Magento2: automatically send email when shipment is created from invoice

unfortunately this not helped... maybe static content should be re-reployed or something like this?