You can copy vendor/magento/module-sales/view/frontend/email/shipment_new.html to your theme and edit line 56 (here you can change block for which display track information), you can change it like this
1 2 3 4 5 6 |
{{ block class='Your_Package\\Your_Module\\Block\\Sales\\Email\\Shipment\\Track' area='frontend' template='Magento_Sales::email/shipment/track.phtml' shipment=$shipment order=$order }} |
After that you need create this block
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
<?php namespace Your_Package\Your_Module\Block\Sales\Email\Shipment; use \Magento\Framework\View\Element\Template; class Track extends Template { /** * @var \Magento\Shipping\Model\Order\TrackFactory */ protected $_trackFactory; /** * Constructor * * @param \Magento\Shipping\Model\Order\TrackFactory $trackFactory * @param Template\Context $context * @param array $data */ public function __construct( \Magento\Shipping\Model\Order\TrackFactory $trackFactory, Template\Context $context, array $data = []) { $this->_trackFactory = $trackFactory; parent::__construct($context, $data); } /** * Retrieve tracking by tracking entity id * * @return array */ public function getTrackingInfoByTrackId($trackId) { /** @var \Magento\Shipping\Model\Order\Track $track */ $track = $this->_trackFactory->create()->load($trackId); if ($track->getEntityId()) { $result = $track->getNumberDetail(); } else { $result = null; } return $result; } } |
Then copy template vendor/magento/module-sales/view/frontend/templates/email/shipment/track.phtml to your theme and change line 25 to
1 2 3 4 5 6 7 8 9 10 11 12 13 |
<td> <?php $trackingInfo = $block->getTrackingInfoByTrackId($_item->getEntityId()); ?> <?php if ($trackingInfo->getUrl()): ?> <a href="<?= $block->escapeHtml($trackingInfo->getUrl()) ?>" onclick="this.target='_blank'"> <?= $block->escapeHtml($_item->getNumber()) ?> </a> <?php else: ?> <?= $block->escapeHtml($_item->getNumber()) ?> <?php endif; ?> </td> |
You also may need copy vendor/magento/module-sales/view/frontend/email/shipment_new_guest.html the same like shipment_new.html
Thank for reading this post, Hope it helps.