Magento: Show “track your order” in frontend – My Orders
It is always required for the customer to track their order. The shipping carriers can be anything: Aramex, Bluedart, DHL, First Flight, Federal Express, etc.. Navigate to My Account and place a button in My Orders section there “Track Order”. Paste the code below to link it to tracking popup that you can also see in backend Shipments area.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | <?php
if($_order->hasShipments()) {
$show = true;
foreach($_order->getTracksCollection() as $k=>$v) {
if($v['carrier_code'] == 'custom' || $v['carrier_code'] == '')
$show = false;
}
if($show) {?>
<span class="separator2"> </span>
<a class="askTrackBtn" href="javascript:;" onclick="popWin('<?php echo Mage::helper('shipping/data')->getTrackingPopUpUrlByOrderId($_order->getId()) ?>', 'tracking the order', 'scrollbars=yes,width=800,height=600,resizable=yes');return false;"><span><?php echo $this->__('Track Order') ?></span></a>
<?php
}
}?> |
15 Comments
Leave a comment
Welcome to my Blog
Certifications
Honor
Recognition
Contributions
Categories
- Apache (2)
- ChatGPT (1)
- Domain name (2)
- eCommerce (2)
- htaccess (1)
- Humor (3)
- Instagram API (1)
- jQuery (4)
- JSON (1)
- Linux (10)
- Magento (142)
- Magento admin (58)
- Magento Certification (5)
- Magento error (13)
- Magento frontend (68)
- Magento Imagine (2)
- Magento Interview (5)
- Magento Master (2)
- Magento2 (10)
- Mobile (1)
- MySQL (7)
- OpenAI (1)
- OroCRM (2)
- Performance (2)
- PHP (8)
- Prototype JS (3)
- Security (4)
- Wordpress (3)
- XML (2)
Tag Cloud
500 internal server error admin answers attribute bug category checkbox checkout cookie customer difference domain name EAV error event extension interview invoice jquery linux magento magento2 magento admin magento error magento interview questions magento orm mysql observer order pinterest product products questions redirect register remove script session simplexml to array state status study guide tax url wordpress
Hiya, which file is this change made iin?
How do I edit the track my order link? I am done with the website but this link is going no where. Please help on how to edit this page.
@Jeff, it should be in the file where you want your customer to track their shipment,
app/design/frontend/default/default/template/sales/order/view.phtml
Any idea how to put that link into the header? Or in top.links?
You can place it in header, but the thing is will you get order details in header? Also, header is included in all the pages, your customers would not like to see “Track your Order” in header when you are in homepage or other pages irrelevant to order section right?
nice….
Hey Jeff
put this code in
yourtemplate/sales/order/history.phtml
Cheers!
i place in “history.phtml” and also in ” view.phtml” but it was not getting
i want to insert tracking link to magento from csv, can you please give me any suggestion how can i do it
this never worked….i tried both in history and view. Nothing showed. I wanted to show the pop up link along with all the orders.
Can you tell me what i am doing wrong?
gr8 its working thanks 🙂
i am also not unable to see the code in frontend but i have added the code in “app/design/frontend/default/default/template/sales/order/view.phtml” and “yourtemplate/sales/order/history.phtml” ………get able to see ….tried many times .
thanks
Its way better to use Magento’s own method to check if the order has shipment attached.
getTracksCollection()->count()) : ?>
<a href="#" onclick="popWin('helper(‘shipping’)->getTrackingPopupUrlBySalesModel($_order) ?>’,’trackorder’,’top=0,left=0,width=800,height=600,resizable=yes,scrollbars=yes’); return false;” title=”quoteEscape($this->__(‘Track your order’)) ?>”>__(‘Track your order’) ?>
How to use this code for magento 2.please help me.
How to use this code for magento 2,Please help me.