How to modify tracking link target
-
02-10-2020 - |
Question
How to modify the tracking link on both admin and frontend so that when I click on the link track this shipment
, it opens directly to carrier page ?
I want it to open https://www.paket.id/is/MPMTD
instead of magento/shipping/tracking/[...]
This is how I changed the carrier URL:
public function getTrackingInfo($tracking)
{
$track = Mage::getModel('shipping/tracking_result_status');
$track->setUrl('https://www.paket.id/is/' . $tracking)
->setTracking($tracking)
->setCarrierTitle($this->getConfigData('name'));
return $track;
}
I have googled how to modify this pop-up but I didn't find any solution. And, is it possible to modify it?
Solution
I had a bit of a struggle with this one, but I found how to do it.
Copy this file /app/design/adminhtml/default/default/template/sales/order/view/tab/info.phtml
to your theme if you have one, or modify it directly (I'd advise against it).
Then around lines 60 you should see something like this:
<a href="#" id="linkId" onclick="popWin('<?php echo $this->helper('shipping')->getTrackingPopupUrlBySalesModel($_order) ?>','trackorder','width=800,height=600,resizable=yes,scrollbars=yes')" title="<?php echo $this->__('Track Order') ?>"><?php echo $this->__('Track Order') ?></a>
If you are using PHP >= 5.5 replace it with :
<?php
echo array_shift(
Mage::getModel('shipping/info')->loadByHash(Mage::helper('core')->urlEncode("order_id:{$_order->getId()}:{$_order->getProtectCode()}"))->getTrackingInfo()
)[0]->getData('status');
?>
if using PHP < 5.5 do this:
<?php
$firstTrack = array_shift(Mage::getModel('shipping/info')->loadByHash(Mage::helper('core')->urlEncode("order_id:{$_order->getId()}:{$_order->getProtectCode()}"))->getTrackingInfo());
$trackLink = $firstTrack[0]->getData('status');
echo $trackLink;
?>