Change the Tracking Information Shipment # to Order #
-
13-12-2019 - |
Question
I'm trying to change the pop-up window when customers track their orders, the pop-up currently shows:
"Shipment #" I would like to change this to the actual order number.
I have tried the following:
<h2 class="sub-title"><?php echo $this->__('Order #'),$_order->getRealOrderId();?></h2>
But it doesn't load.
The original file is located in:
default/template/shipping/tracking/popup.phtml
How can I display the Order # instead of the Shipment # on this pop up?
Solution
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());
OTHER TIPS
I had nearly the same problem and needed some information from the shipment address of the order for a tracking link. The following code worked for me in the popup.phtml (Magento 1.9.1.0):
$shippingInfoModel = Mage::getModel('shipping/info')->loadByHash($this->getRequest()->getParam('hash'));
if (array_key_exists('order_id', $shippingInfoModel->_data)) {
$order_id = $shippingInfoModel->_data['order_id'];
$order = Mage::getModel('sales/order')->load($order_id);
}
if (array_key_exists('ship_id', $shippingInfoModel->_data)) {
$ship_id = $shippingInfoModel->_data['ship_id'];
$order_shipment = Mage::getModel('sales/order_shipment')->load($ship_id);
$order = $order_shipment->getOrder();
}
Using $order you can get now the order number: $order->getIncrementId();