Magento Forum

   
Page 2 of 2
Make tracking number on receipt a link to carrier tracking info. 
 
thalbach
Jr. Member
 
Total Posts:  2
Joined:  2011-04-06
 

Alternate code to link to the built-in Magento tracking function on your site:

Replace: (Line 41 of <theme>/template/email/order/shipment/track.phtml)

<td align="center" valign="top" style="padding:3px 9px"><?php echo $_item->getNumber() ?></td>

With:

<?php $url $this->helper('shipping')->getTrackingPopupUrlBySalesModel($_order?>
      <?php 
if ($url): ?>
        
<td align="center" valign="top" style="padding:3px 9px"><a href="<?=$url?>"><?php echo $_item->getNumber() ?></a></td>
      
<?php else: ?>
        
<td align="center" valign="top" style="padding:3px 9px"><?php echo $_item->getNumber() ?></td>
      
<?php endif; ?>

And that’ll link to your on-site Magento order tracker.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Erma
Member
 
Total Posts:  31
Joined:  2011-04-30
 
djsinestro - 04 December 2009 11:33 AM

I was just playing with this and got it working, but this is a total hack. Works for UPS, FedEx, USPS, and DHL via Boxoh.com.

In app/design/frontend/default/default/template/email/order/shipment open “track.phtml”

Change line 81 from:

<td align="center" valign="top" style="padding:3px 9px"><?php echo $_item->getNumber() ?></td>

To:
<td align="center" valign="top" style="padding:3px 9px"><?php echo "<a href= 'http://boxoh.com/?t=".$_item->getNumber()."'>".$_item->getNumber()."</a>" ?></td>

This turns your tracking number into a link on Boxoh.

Hope it helps someone.

It works perfectly on 1.5. Thanks

 
Magento Community Magento Community
Magento Community
Magento Community
 
sterg17
Sr. Member
 
Total Posts:  94
Joined:  2009-11-06
 
roberthenderson - 02 May 2011 08:49 AM

Hey guys, if you don’t want to use the Carrier Title in your code, you can use getCarrierCode().  The four codes are usps, ups, dhl, and fedex.  See new code below:

<td align="left" valign="top" style="padding:3px 9px"><?php echo $_item->getTitle() ?></td>
            
<?php if ($_item->getCarrierCode()=='usps'): ?>
                 
<td align="center" valign="top" style="padding:3px 9px"><a href "http://trkcnfrm1.smi.usps.com/PTSInternetWeb/InterLabelInquiry.do?origTrackNum=<?php echo $_item->getNumber() ?>"><?php echo $_item->getNumber() ?></a></td>
            
<?php elseif ($_item->getCarrierCode()=='ups'): ?>
                 
<td align="center" valign="top" style="padding:3px 9px"><a href="http://wwwapps.ups.com/WebTracking/processInputRequest?tracknum=<?php echo $_item->getNumber() ?>"><?php echo $_item->getNumber() ?></a></td>
            
<?php elseif ($_item->getCarrierCode()=='dhl'): ?>
                 
<td align="center" valign="top" style="padding:3px 9px"><a href="http://track.dhl-usa.com/TrackByNbr.asp?ShipmentNumber=<?php echo $_item->getNumber() ?>"><?php echo $_item->getNumber() ?></a></td>
            
<?php elseif ($_item->getCarrierCode()=='fedex'): ?>
                 
<td align="center" valign="top" style="padding:3px 9px"><a href="http://www.fedex.com/Tracking?tracknumbers=<?php echo $_item->getNumber() ?>"><?php echo $_item->getNumber() ?></a></td>
            
<?php else: ?>
                 
<td align="center" valign="top" style="padding:3px 9px"><?php echo $_item->getNumber() ?></td>
            
<?php endif; ?>

This worked great to get the tracking number number clickable when I would go to Admin -> Send Tracking Info.  But, it doesnt work when a new order is shipped, and the tracking information is added to database.  The email that is sent to the customer, still have the OLD method where the tracking number is NOT clickable.

Would there be any reason why when a new shipment is created, the tracking number is NOT CLICKABLE, but when I manually select “Send Tracking Information” from each shipment, the correct clickable number is sent?

Thanks!

 
Magento Community Magento Community
Magento Community
Magento Community
 
Giftapolis
Jr. Member
 
Total Posts:  1
Joined:  2012-08-28
 

Were you ever able to resolve this issue, which we are also experiencing?

sterg17 - 22 August 2012 12:04 PM

roberthenderson - 02 May 2011 08:49 AM
Hey guys, if you don’t want to use the Carrier Title in your code, you can use getCarrierCode().  The four codes are usps, ups, dhl, and fedex.  See new code below:
<td align="left" valign="top" style="padding:3px 9px"><?php echo $_item->getTitle() ?></td>
            
<?php if ($_item->getCarrierCode()=='usps'): ?>
                 
<td align="center" valign="top" style="padding:3px 9px"><a href "http://trkcnfrm1.smi.usps.com/PTSInternetWeb/InterLabelInquiry.do?origTrackNum=<?php echo $_item->getNumber() ?>"><?php echo $_item->getNumber() ?></a></td>
            
<?php elseif ($_item->getCarrierCode()=='ups'): ?>
                 
<td align="center" valign="top" style="padding:3px 9px"><a href="http://wwwapps.ups.com/WebTracking/processInputRequest?tracknum=<?php echo $_item->getNumber() ?>"><?php echo $_item->getNumber() ?></a></td>
            
<?php elseif ($_item->getCarrierCode()=='dhl'): ?>
                 
<td align="center" valign="top" style="padding:3px 9px"><a href="http://track.dhl-usa.com/TrackByNbr.asp?ShipmentNumber=<?php echo $_item->getNumber() ?>"><?php echo $_item->getNumber() ?></a></td>
            
<?php elseif ($_item->getCarrierCode()=='fedex'): ?>
                 
<td align="center" valign="top" style="padding:3px 9px"><a href="http://www.fedex.com/Tracking?tracknumbers=<?php echo $_item->getNumber() ?>"><?php echo $_item->getNumber() ?></a></td>
            
<?php else: ?>
                 
<td align="center" valign="top" style="padding:3px 9px"><?php echo $_item->getNumber() ?></td>
            
<?php endif; ?>

This worked great to get the tracking number number clickable when I would go to Admin -> Send Tracking Info.  But, it doesnt work when a new order is shipped, and the tracking information is added to database.  The email that is sent to the customer, still have the OLD method where the tracking number is NOT clickable.

Would there be any reason why when a new shipment is created, the tracking number is NOT CLICKABLE, but when I manually select “Send Tracking Information” from each shipment, the correct clickable number is sent?

Thanks!

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top
Page 2 of 2