How do I add a tracking link to mail template?

Here is what I tried:

In System > Transactional Emails I opened the template for Shipment Email Template for Guest (GLOBAL). I thought tracking numbers are included here:

{{block type='core/template' area='frontend' template='email/order/shipment/track.phtml'
  shipment=$shipment order=$order}}

So I copied email/order/shipment/track.phtml into my template and added a tracking link but it does not show up in the email:

<td align="center" valign="top" style="padding:3px 9px"><a href="http://nolp.dhl.de/nextt-online-public/set_identcodes.do?lang=de&idc=<?php echo $_item->getNumber() ?>"><?php echo $_item->getNumber() ?></a></td>

The problem is that this is PHP code:

<td align="center" valign="top" style="padding:3px 9px">
<a href="http://nolp.dhl.de/nextt-online-public/set_identcodes.do?lang=de&idc=
<?php echo $_item->getNumber() ?>">
<?php echo $_item->getNumber() ?></a>

You can't execute PHP from inside of an email template - instead, look to a tutorial to implement:


Or an extension:


This plugin has the following feature which sounds handy to insert into your transactional shipment email: "Ability to insert order tracking link via widget and CMS"

  • The PHP code is not in the template but in a block the template includes. Anyway that does work, I have the tracking number in the email. What I am missing is my HTML link around it. I am guessing the block generation in emails ignores my template but I don't want to change /app/design/frontend/base/default/ – PiTheNumber Jul 5 '13 at 6:46

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