1

I want to add the tracking no to an email, just the number not url.

what is the tracking # variable ?

update

I have modifed the code in track.phtml to this

?>
<?php $_shipment=$this->getShipment() ?>
<?php $_order=$this->getOrder() ?>
<?php if ($_shipment && $_order && $_shipment->getAllTracks()): ?>
<?php $i=0; foreach ($_shipment->getAllTracks() as $_item): $i++ ?>
<?php echo $this->escapeHtml($_item->getNumber()) ?>
<?php endforeach ?>
<?php endif; ?>

but I don't want to have all tracking #, I only want the last added one

how can I do that ?

5
  • What Magento version? May 10, 2016 at 19:49
  • magento 1.9.2.4
    – mubdea
    May 10, 2016 at 19:55
  • Are you calling track.phtml in your email template? May 10, 2016 at 19:56
  • no, it is new empty template I just want to add
    – mubdea
    May 10, 2016 at 20:02
  • tracking # XXXXXXXX where XXXXXXXX is the tracking number for the the order
    – mubdea
    May 10, 2016 at 20:03

2 Answers 2

1

You should include the tracking details using the following code:

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

Let me know if it works

8
  • 1
    this will show complete table with Shipped By Tracking Number and its value. however I only want the value of the tracking #
    – mubdea
    May 10, 2016 at 20:09
  • Duplicate the file and strip out what you don't want May 10, 2016 at 20:12
  • how can I do that ?
    – mubdea
    May 10, 2016 at 20:13
  • I have modified it to this
    – mubdea
    May 10, 2016 at 20:42
  • ?> <?php $_shipment=$this->getShipment() ?> <?php $_order=$this->getOrder() ?> <?php if ($_shipment && $_order && $_shipment->getAllTracks()): ?> <?php $i=0; foreach ($_shipment->getAllTracks() as $_item): $i++ ?> <?php echo $this->escapeHtml($_item->getNumber()) ?> <?php endforeach ?> <?php endif; ?>
    – mubdea
    May 10, 2016 at 20:42
1

I've been trying to just get the last track aswell, so i modified the track.phtml to this:

<?php
$_shipment=$this->getShipment();
$_order=$this->getOrder();
if ($_shipment && $_order && $_shipment->getAllTracks()):
$i=0;
$tracks = array();
foreach($_shipment->getAllTracks() as $_item): 
    $i++;
    $tracks[] = $this->escapeHtml($_item->getNumber());
endforeach;

echo $tracks[count($tracks)-1];
endif;
?>

Then I just include the Track-id in the email with:

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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