If I understand you correctly, you are trying to add information based on the carrier code
.
When creating a shipment, if you add tracking details, then you have carrier_code
in there. Check this table:
Check \vendor\magento\module-sales\view\frontend\templates\email\shipment\track.phtml
. This is the file responsible for sending tracking detail
in shipment email.
And you can get the carrier code inside the tracking loop:
$_item->getCarrierCode()
To customize this file, just copy the file to your theme:
/app/design/frontend/YourTheme/ThemeName/tempaltes/email/shipment/track.phtml
Hope this helps.
UPDATE
In order to add tracking info to your custom shipping method, you should add getTrackingInfo($trackingNumber)
function in your carrier (Namespace/Module/Model/Carrier/YourCarrier.php
).
/**
* Get tracking information. Original return value annotation is misleading.
*
* @see \Magento\Shipping\Model\Carrier\AbstractCarrier::isTrackingAvailable()
* @see \Magento\Shipping\Model\Carrier\AbstractCarrierOnline::getTrackingInfo()
* @see \Magento\Dhl\Model\Carrier::getTracking()
* @param string $trackingNumber
* @return \Magento\Shipping\Model\Tracking\Result\AbstractResult
*/
public function getTrackingInfo($trackingNumber)
{
/** @var \Magento\Shipping\Model\Tracking\Result\Status $tracking */
$tracking = $this->trackStatusFactory->create();
$title = $this->getConfigData('title');
$tracking->setCarrier($this->_code); //your carrier code
$tracking->setCarrierTitle($title);
$tracking->setTracking($trackingNumber);
//you may want to add the events coming from your api
$trackEventsData [] =
[
'deliverydate' => 'date',
'deliverytime' => 'time',
'deliverylocation' => 'location',
'activity' => 'activity'
];
$tracking->setStatus(isset($trackEventsData[0]) ? $trackEventsData[0]['activity'] : '');
$tracking->setProgressdetail($trackEventsData);
return $tracking;
}