Question

I like to add tracking ID link for my shipping email template form. Please advice me to do this process.

Was it helpful?

Solution

Please override this file:

vendor/magento/module-sales/view/frontend/templates/email/shipment/track.phtml

by creating this path:

/app/design/frontend/Custom/theme/Magento_Sales/templates/email/shipment/track.phtml

Please add below code in foreach loop

<?php
$trackurl = '';
if($_item->getCarrierCode() === 'fedex'){
    $trackurl = 'https://www.fedex.com/apps/fedextrack/?action=track&trackingnumber='.$_item->getNumber();
}elseif ($_item->getCarrierCode() === 'usps') {
    $trackurl = 'https://tools.usps.com/go/TrackConfirmAction_input?qtc_tLabels1='.$_item->getNumber();
}elseif ($_item->getCarrierCode() === 'ups') {
    $trackurl = 'https://wwwapps.ups.com/WebTracking/returnToDetails?tracknum='.$_item->getNumber();
}
?>
<tr>
    <td><?= $block->escapeHtml($_item->getCarrierCode()) ?>:</td>

     <td style="padding:3px 9px"><a href="<?php echo $trackurl ?>"><?php echo $this->escapeHtml($_item->getNumber()) ?></a></td>

</tr>
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top