0

I have created a shipment by adding Tacking info. I am getting the shipment email with empty Tacking info.

Next time if i click on "send Tracking Information. Then I will get the tracking info in shipment email.

My Magento version is 2.3.5

here is the screenshot of shipment email enter image description here

I need to get this info during shipment creation.

Hopefully its because i used this event to send shipment email automatically whenever the shipment is created.

Vendor/Module/etc/events.xml

<event name="sales_order_shipment_save_after">
    <observer name="sales_order_shipment_after"
              instance="Vendor\Module\Observer\SalesOrderShipmentAfter" />
</event>

Vendor/Module/Observer/SalesOrderShipmentAfter.php

use Magento\Framework\Event\ObserverInterface;
class SalesOrderShipmentAfter implements ObserverInterface
{
    protected $shipmentNotifier;
    protected $_logger;
    public function __construct(
    \Psr\Log\LoggerInterface $logger,       
    \Magento\Shipping\Model\ShipmentNotifier $shipmentNotifier
) {
    $this->_logger = $logger;
    $this->shipmentNotifier = $shipmentNotifier;
}
public function execute(\Magento\Framework\Event\Observer $observer)
{
    try{
        $this->_logger->info('inside shipment observer');
        $shipment = $observer->getEvent()->getShipment();
        $this->shipmentNotifier->notify($shipment);
        //$shipment->save();
    }catch (\Exception $e) {
        $this->_logger->info('--shipment observer--'.$e->getMessage());
    } 
  }
}

Can anyone please help me on this. Thanks

  • Is happen when you trying to sent from admin? – Amit Bera Jun 29 at 6:28
  • @AmitBera, yes, whenever we create shipment from admin, by selecting send an email copy checkbox – Manjunath Jun 29 at 6:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.