How to Display “Track My Order” Links in Hyvä

In this guide, you can learn how to add the “Track My Order” links to the footer and header in Hyvä theme for the Magento 2 Order Status & Shipping Tracking Pro Extension.

First, check if your theme includes a Magento_Theme::html/header.phtml file. If the file is missing, please copy the following file:

vendor/hyva-themes/magento2-default-theme/Magento_Theme/templates/html/header.phtml

to the theme with the following path: app/design/frontend/<theme_vendor>/<theme_name>/Magento_Theme/templates/html/footer/links.phtml

Next, in order to display the “Track My Order” link in the header, add the code below to the Magento_Theme::html/header.phtml file.

<!--Track My Order Icon-->
<?php
/** @var \Hyva\PlumrocketShippingTrackingPro\ViewModel\TrackMyOrder $prOrderStatus */
$prOrderStatus = $viewModels->require(\Hyva\PlumrocketShippingTrackingPro\ViewModel\TrackMyOrder::class);
?>
<?php if ($prOrderStatus->canShowInHeader()): ?>
    <a id="pr-header-tracking-link"
       class="inline-block ml-1 no-underline sm:ml-3 hover:text-black"
       href="<?= $escaper->escapeUrl($prOrderStatus->getTrackLink()) ?>">
        <span class="sr-only label">
            <?= $escaper->escapeHtml(__($prOrderStatus->getHeaderTrackLinkLabel())) ?>
        </span>
        <?= $heroicons->locationMarkerHtml("w-8 h-8 md:h-6 md:w-6 hover:text-black", 25, 25) ?>
    </a>
<?php endif; ?>

First, check if your theme includes a Magento_Theme::html/footer/links.phtml file. If the file is missing, please copy the following file:

vendor/hyva-themes/magento2-default-theme/Magento_Theme/templates/html/footer/links.phtml

to the theme with the following path:

app/design/frontend/<theme_vendor>/<theme_name>/Magento_Theme/templates/html/footer/links.phtml

Next, in order to add the “Track My Order” link in the footer, add the code below to the Magento_Theme::html/footer/links.phtml file.

<?php
/** @var \Hyva\PlumrocketShippingTrackingPro\ViewModel\TrackMyOrder $prOrderStatus */
$prOrderStatus = $viewModels->require(\Hyva\PlumrocketShippingTrackingPro\ViewModel\TrackMyOrder::class);
?>
<?php if ($prOrderStatus->canShowInFooter()): ?>
    <li class="mt-4">
        <a href="<?= $escaper->escapeUrl($prOrderStatus->getTrackLink()) ?>"
           class="text-base leading-6">
            <?= $escaper->escapeHtml($prOrderStatus->getFooterTrackLinkLabel()) ?>
        </a>
    </li>
<?php endif; ?>

Step 3. Apply Changes

This step is necessary only when the FPC cache is enabled or when using Magento in production mode. If either of these conditions applies to you, please run the following commands to apply the changes:

php bin/magento setup:static-content:deploy
php bin/magento cache:flush
Was this article helpful?