Skip to content

Custom Attribute on order confirmation email in Magento 2.4.5

I’m trying to publish the custom attribute “flash_sale” (dropdown) on order confirmations.

I’ve changed the file:

vendor/magento/module-sales/view/frontend/templates/email/items/order/default.phtml

and inserted the additional line:

<p style="color: #aaaaaa;"><?= /* @escapeNotVerified */  __('Flash Sale') ?>: <?= $block>escapeHtml($block->getflash_sale()) ?></p>

with the result:

     <td class="item-info<?php if ($block->getItemOptions()): ?> has-extra<?php endif; ?>" colspan="2" style="position: relative !important; border-top: 0 none !important; padding: 35px 10px; border-bottom: 1px dotted #000000;">
    <p class="item-name" style="margin-top: 0 !important;"><?= $block->escapeHtml($_item->getName()) ?></p>
    <div class="item-detail" style="margin: 5px 0; font-size: 12px;">
    <p style="color: #aaaaaa;"><?= /* @escapeNotVerified */  __('Item') ?>: <?= $block->escapeHtml($block->getSku($_item)) ?></p>
     <p style="color: #aaaaaa;"><?= /* @escapeNotVerified */  __('Flash Sale') ?>: <?= $block>escapeHtml($block->getflash_sale()) ?></p>
        <?php if ($block->getItemOptions()): ?>
            <?php foreach ($block->getItemOptions() as $option): ?>
                <p style="color: #aaaaaa"><?= /* @escapeNotVerified */  $option['label']. ': ' . nl2br($option['value'])?></p>
            <?php endforeach; ?>

But the value is not published on order confirmations. What went wrong?

Thank you advance!