Showing results for 
Search instead for 
Did you mean: 

Shipment Email Template Edit

Shipment Email Template Edit



I am looking for some help with customising the shipment email template.


We would like to add the list of items not yet dispatched (if applicable) to the bottom of the template.


Does anybody know how I can do this?


Thanks in advance!!



Re: Shipment Email Template Edit

Lets Take an Example to Override the shipping email template to add the tracking link in the email, In the same way you can override the shipping.html files to show the dispatched items.

For Overriding the Shipping Template Follow the steps : 

1) Override the core magento items.phtml file in your current them


2) After adding the file, add the logic in track.phtml

 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
<?php /* @var \Magento\Framework\View\Element\Template $block */ ?>
<?php $_shipment = $block->getShipment() ?>
/* @var \Magento\Sales\Model\Order $_order */
$_order = $block->getOrder() ?>
<?php if ($_shipment && $_order) : ?>
    <?php $trackCollection = $_order->getTracksCollection($_shipment->getId()) ?>
    <?php if ($trackCollection) : ?>
        <br />
        <table class="shipment-track">
                <th><?= $block->escapeHtml(__('Shipped By')) ?></th>
                <th><?= $block->escapeHtml(__('Tracking Number')) ?></th>
            <?php foreach ($trackCollection as $_item) : ?>
                    <td><?= $block->escapeHtml($_item->getTitle()) ?>:</td>
                        <?php if ($_item->getTitle() == 'GLS') { ?>
                            <a href="<?= $_item->getNumber() ?>" target="_blank">
                                <?= $block->escapeHtml($_item->getNumber()) ?>
                        <? } elseif ($_item->getTitle() == 'DHL') { ?>
                            <a href="<?= $_item->getNumber() ?>" target="_blank">
                                <?= $block->escapeHtml($_item->getNumber()) ?>
                        <? } elseif ($_item->getTitle() == 'POST AT') { ?>
                            <a href="<?= $_item->getNumber() ?>" target="_blank">
                                <?= $block->escapeHtml($_item->getNumber()) ?>
                        <? } else { ?>
                            <a href="<?= $block->escapeUrl($block->getTrackingUrl()->getUrl($_item)) ?>" target="_blank">
                                <?= $block->escapeHtml($_item->getNumber()) ?>
                        <? } ?>
            <?php endforeach ?>
    <?php endif; ?>
<?php endif; ?>

In the similar way you can override the file : 


and add the logic in the overridden file.

3) Delete the contents of :


4) Run the Magento deploy commands :

php bin/magento setup:static-content:deploy -f
php bin/magento cache:flush

Clean the cache in your web browser and try to view your page that you want to override.

Hope this is clear enough and works for you.

Problem solved? Click Kudos & Accept as Solution!


Re: Shipment Email Template Edit

When your job is to be in charge of email templates, you go through a lot of them. So many that you start to develop an eye for the right templates—the ones that are just right for communicating with an audience of people on different levels and with different needs. Some people will be picky about details and want things spelled out exactly; others just want to know the basic facts and will fill in the rest themselves. Some templates call for a serious, official tone; others require a breezier, friendlier touch. I found the right ones when searching for family-feud docs&slides.