1

I am trying to build a custom module that will trigger off a text message when Magento receives shipping information on orders.

I know I can trigger off email, sms etc when an order is placed by listening for the event 'order' referring to this line

$this->_eventManager->dispatch('sales_order_place_after', ['order' => $this]); 

In this php file

Magento/Sales/Model/Order.php 

So my question is where can I find the event that triggers the default email that gets send when a shipment is generated in Magento2?

2 Answers 2

2

sales_order_shipment_save_after

<?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd"> <event name="sales_order_shipment_save_after"> <observer name="myname" instance="Vendor\MyModule\Observer\ProcessShipment" /> </event> </config> 

then use it like this

<?php namespace Vendor\MyModule\Observer; use Magento\Framework\Event\ObserverInterface; class ProcessShipment implements ObserverInterface { /** * * @param \Magento\Framework\Event\Observer $observer * @return $this */ public function execute(\Magento\Framework\Event\Observer $observer) { $shipment = $observer->getEvent()->getShipment(); $order = $shipment->getOrder(); // your code here } } 
2

Open vendor/magento/module-shipping/Controller/Adminhtml/Order/Shipment/Save.php and check the following line:

if (!empty($data['send_email']) && $this->salesData->canSendNewShipmentEmail()) { $this->shipmentSender->send($shipment); } 

Following class is responsible: vendor/magento/module-sales/Model/Order/Email/Sender/ShipmentSender.php

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.