cancel
Showing results for 
Search instead for 
Did you mean: 

Shipment Email Template Edit

Shipment Email Template Edit

Hello!!

 

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!!

Josh

2 REPLIES 2

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

<magento-root>/vendor/magento/module-sales/view/frontend/templates/email/shipment/track.phtml
app/design/frontend/Vendor/Theme/Magento_Sales/templates/email/shipment/track.phtml


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

<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
?>
<?php /* @var \Magento\Framework\View\Element\Template $block */ ?>
<?php $_shipment = $block->getShipment() ?>
<?php
/* @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">
            <thead>
            <tr>
                <th><?= $block->escapeHtml(__('Shipped By')) ?></th>
                <th><?= $block->escapeHtml(__('Tracking Number')) ?></th>
            </tr>
            </thead>
            <tbody>
            <?php foreach ($trackCollection as $_item) : ?>
                <tr>
                    <td><?= $block->escapeHtml($_item->getTitle()) ?>:</td>
                    <td>
                        <?php if ($_item->getTitle() == 'GLS') { ?>
                            <a href="http://www.gls-group.eu/276-I-PORTAL-WEB/content/GLS/DE03/DE/5004.htm?txtRefNo=<?= $_item->getNumber() ?>" target="_blank">
                                <?= $block->escapeHtml($_item->getNumber()) ?>
                            </a>
                        <? } elseif ($_item->getTitle() == 'DHL') { ?>
                            <a href="http://nolp.dhl.de/nextt-online-public/set_identcodes.do?lang=de&idc=<?= $_item->getNumber() ?>" target="_blank">
                                <?= $block->escapeHtml($_item->getNumber()) ?>
                            </a>
                        <? } elseif ($_item->getTitle() == 'POST AT') { ?>
                            <a href="https://www.post.at/sendungsverfolgung.php/details?pnum1=<?= $_item->getNumber() ?>" target="_blank">
                                <?= $block->escapeHtml($_item->getNumber()) ?>
                            </a>
                        <? } else { ?>
                            <a href="<?= $block->escapeUrl($block->getTrackingUrl()->getUrl($_item)) ?>" target="_blank">
                                <?= $block->escapeHtml($_item->getNumber()) ?>
                            </a>
                        <? } ?>
                    </td>
                </tr>
            <?php endforeach ?>
            </tbody>
        </table>
    <?php endif; ?>
<?php endif; ?>


In the similar way you can override the file : 

/vendor/magento/module-checkout/view/frontend/web/template/shipping.html

and add the logic in the overridden file.

3) Delete the contents of :

/var/viewprocessed/*
/pub/static/frontend/*

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.