2

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

4

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>

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.