---
title: "Magento 2: Add Track Order link with the Order on Order History Page"
url: "https://magecomp.com/blog/magento-2-add-track-order-link-on-order-history-page/"
date: "2020-10-16T16:45:45+00:00"
modified: "2025-02-20T10:51:33+00:00"
author:
  name: "Dhiren Vasoya"
  url: "https://magecomp.com/"
categories:
  - "How To"
  - "Magento 2"
word_count: 904
reading_time: "5 min read"
summary: "Hello Magento Friends ?,"
description: "Let your Magento 2 customers track the order easily with the order tracking link on the order history page. Check out how to implement it."
keywords: "How To, Magento 2"
language: "en"
schema_type: "Article"
related_posts:
  - title: "10 Best M2 Checkout Success Page Plugins for Attractive Thank You Pages"
    url: "https://magecomp.com/blog/best-magento-2-checkout-success-page-plugins/"
  - title: "Magento 2: How to Create/Add Custom Cache Type in Cache List"
    url: "https://magecomp.com/blog/magento-2-create-add-custom-cache-type-in-cache-list/"
  - title: "How to Use Encryption and Decryption in Magento 2"
    url: "https://magecomp.com/blog/use-encryption-decryption-magento-2/"
---

# Magento 2: Add Track Order link with the Order on Order History Page

_Published: October 16, 2020_  
_Author: Dhiren Vasoya_  

![Add Track Order link with the Order on Order History Page](https://magecomp.com/blog/wp-content/uploads/2020/10/Add-Track-Order-link-with-the-Order-on-Order-History-Page-1024x512.webp)

**Hello Magento Friends ?,**

Welcome back to Magento Technical Blog series. Today I will throw light on Magento 2: Add Track Order link with the Order on Order History Page. Look at what our previous blog has to say, [**How to add Stock Status column in Admin Product Grid Magento 2**](https://magecomp.com/blog/how-to-add-stock-status-column-in-admin-product-grid-magento-2/).
[![Magento version upgrade](https://magecomp.com/blog/wp-content/uploads/2025/02/Magento-2-Version-Upgrade-CTA-2.webp)](https://magecomp.com/services/magento-upgrade-services/)

As soon as the customer places an order, he/she is eager to know about when their products will arrive. An order tracking process allows the customer to know the status of their orders like pending, processing, shipped, delivered. My orders section displays the order information that comprises information like the order number, date, amount, status, etc. What if you want to provide an order tracking link to the customers of your Magento 2 store into their My Orders page?
Let us know How to Add Track Order link with the Order on Order History Page in Magento 2 ?
## How to Add Track Order link with the Order on Order History Page in Magento 2:
Copy the **vendor/magento/module-sales/view/frontend/templates/order/history.phtml** file in your theme under the below path:
**app/design/frontend/Themes/Yourtheme/Magento_Sales/templates/order/history.phtml**
Now, add the below code:
```
<?php $_orders = $block->getOrders(); ?>
<?= $block->getChildHtml('info') ?>
<?php if ($_orders && count($_orders)): ?>
            <table class="data table table-order-items history" id="my-orders-table">
            <caption class="table-caption"><?= /* @escapeNotVerified */
                __('Orders') ?></caption>
            <thead>
            <tr>
                <th scope="col" class="col id"><?= /* @escapeNotVerified */
                    __('Order #') ?></th>
                <th scope="col" class="col date"><?= /* @escapeNotVerified */
                    __('Date') ?></th>
                <?= /* @noEscape */
                $block->getChildHtml('extra.column.header') ?>
                <th scope="col" class="col shipping"><?= /* @escapeNotVerified */
                    __('Ship To') ?></th>
                <th scope="col" class="col total"><?= /* @escapeNotVerified */
                    __('Order Total') ?></th>
                <th scope="col" class="col status"><?= /* @escapeNotVerified */
                    __('Status') ?></th>
                <th scope="col" class="col actions"><?= /* @escapeNotVerified */
                    __('Action') ?></th>
                <th scope="col" class="col actions">Track Order</th>
            </tr>
            </thead>
            <tbody>
            <?php foreach ($_orders as $_order): ?>
                <tr>
                    <td data-th="<?= $block->escapeHtml(__('Order #')) ?>" class="col id"><?= /* @escapeNotVerified */
                        $_order->getRealOrderId() ?></td>
                    <td data-th="<?= $block->escapeHtml(__('Date')) ?>" class="col date"><?= /* @escapeNotVerified */
                        $block->formatDate($_order->getCreatedAt()) ?></td>
                    <?php $extra = $block->getChildBlock('extra.container'); ?>
                    <?php if ($extra): ?>
                        <?php $extra->setOrder($_order); ?>
                        <?= /* @noEscape */
                        $extra->getChildHtml() ?>
                    <?php endif; ?>
                    <td data-th="<?= $block->escapeHtml(__('Ship To')) ?>"
                        class="col shipping"><?= $_order->getShippingAddress() ? $block->escapeHtml($_order->getShippingAddress()->getName()) : '&nbsp;' ?></td>
                    <td data-th="<?= $block->escapeHtml(__('Order Total')) ?>"
                        class="col total"><?= /* @escapeNotVerified */
                        $_order->formatPrice($_order->getGrandTotal()) ?></td>
                    <td data-th="<?= $block->escapeHtml(__('Status')) ?>"
                        class="col status"><?= /* @escapeNotVerified */
                        $_order->getStatusLabel() ?></td>
                    <td data-th="<?= $block->escapeHtml(__('Actions')) ?>" class="col actions">
                        <a href="&lt;?= /* @escapeNotVerified */
                        $block-" data-wpel-link="internal" target="_blank" rel="follow">getViewUrl($_order) ?>" class="action view">
                            <?= /* @escapeNotVerified */
                                __('View Order') ?>                        </a>
                        <?php if ($this->helper('MagentoSalesHelperReorder')->canReorder($_order->getEntityId())) : ?>
                            <a href="#" data-post="&lt;?php /* @escapeNotVerified */
                            echo
                            $this-">helper(MagentoFrameworkDataHelperPostHelper::class)
                                ->getPostData($block->getReorderUrl($_order))
                            ?>' class="action order">
                                <?= /* @escapeNotVerified */
                                    __('Reorder') ?>                            </a>
                        <?php endif ?>
                    </td>
                    <td class="col actions">
                        <a href="#" class="action track" title="Track Your Order" data-mage-init="{&quot;popupWindow&quot;: {&quot;windowURL&quot;:&quot;&lt;?= $this-">helper('MagentoShippingHelperData')->getTrackingPopupUrlBySalesModel($_order); ?>","windowName":"trackorder","width":800,"height":600,"left":0,"top":0,"resizable":1,"scrollbars":1}}'>
                            Track Your Order                        </a>
                    </td>
                </tr>
            <?php endforeach; ?>
            </tbody>
        </table>
        <?php if ($block->getPagerHtml()): ?>
        <?= $block->getPagerHtml() ?>    <?php endif ?>
<?php else: ?>
    <?= /* @escapeNotVerified */
            __('You have placed no orders.') ?><?php endif ?>
```

[![Magento 2 Speed & Performance Optimization Services](https://magecomp.com/blog/wp-content/uploads/2025/02/Magento-2-Speed-Performance-Optimization-Services-CTA-3.webp)](https://magecomp.com/magento-performance-optimization.html)
Flush the cache after the changes. That’s it.
With the implementation of the above code, the track order column link will be added to the order home page as shown below:
![track-order](https://magecomp.com/blog/wp-content/uploads/2020/10/track-order.png)

## Conclusion:
Expectantly, all are able to Add Track Order link with the Order on Order History Page in Magento 2. Apart from this, increase the customer experience of your store with [**Order Tracking Extension for Magento 2**](https://magecomp.com/magento-2-order-tracking.html), which enables tracking order directly from the customer’s My Account section.
[![hyva theme development](https://magecomp.com/blog/wp-content/uploads/2025/02/hyva-theme-development-CTA-1.webp)](https://magecomp.com/services/hyva-theme-development/)

In case of any issues while implementing the code, notify me in the comment section below. Do share the article with your Magento colleagues and friends. Keep in touch for more such solutions.
**Happy Coding ?**


---

_View the original post at: [https://magecomp.com/blog/magento-2-add-track-order-link-on-order-history-page/](https://magecomp.com/blog/magento-2-add-track-order-link-on-order-history-page/)_  
_Served as markdown by [Third Audience](https://github.com/third-audience) v3.5.3_  
_Generated: 2026-08-19 02:06:48 UTC_  
