You have two requirements here - 1) adding a barcode and 2) adding a tracking number.
Barcode:
Barcodes typically require custom fonts. How are you generating barcodes today? If you find yourself using an external service to render the barcode you can create the image offline and include. Using the font is more complex than the image as you must define a path to font on the server.
This is a good example of the type of work required in a custom module that extends Mage_Sales_Model_Order_Pdf_Packaging
:
/* Define a font path that is readable by the web server */
$fontPath = '/var/www/barcode-fonts/FRE3OF9X.TTF';
/* Load the font */
$page->setFont(Zend_Pdf_Font::fontWithPath($fontPath), 36);
/* Create barcode string. */
/* Note: Asterisks are required for code39 */
$barcodeImage = "*".$order->getIncrementId()."*";
/* Insert the barcode into the page */
$page->drawText($barcodeImage, 400, 800);
Source: http://www.magentocommerce.com/boards/viewthread/15807/
Tracking Number:
Adding the tracking number should be trivial compared to the above solution. The below solution lists tracking number separated 200px vertically from each other. In the same file as the barcode solution above:
$x = 400; $y = 800;
foreach($shipment->getTracksCollection() as $track){
/* Insert the tracking code into the page */
$page->drawText($track->getNumber(), $x, $y+=200);
}
3rd party plugin
There are third-party plugins available that allow you to create more flexible Packing Slip templates, etc. - many have barcodes built in. Here's one:
http://www.magentocommerce.com/magento-connect/moogento-pickpack-pick-lists-packing-sheets-invoices-pdfs-fully-customisable-works-with-all-order-statuses.html
Good luck!
Take a look at app/design/frontend/base/default/layout/shipping.xml to find the block for this template.
<reference name="content">
<block type="shipping/tracking_popup" name="shipping.tracking.popup" template="shipping/tracking/popup.phtml" />
</reference>
Now if you take a look at Mage_Shipping_Block_Tracking_Popup
you will notice that you can not get the order object directly.
So in your template file try this before your code above
$_order = Mage::getModel('sales/order')->load($this->getOrderId());
Best Answer
Please override this file:
by creating this path:
Please add below code in foreach loop