Magento – Magento2: How to add custom attribute value in Email template

email-templatesmagento2order-email

I want add custom attribute value in new order email template.

Please help me in this.

Best Answer

If the name of the attribute is the following:

your_attribute

Just modify the following template:

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

with copying to:

/app/design/frontend/XXXX/YYYY/Magento_Sales/templates/email/items/order/default.phtml

and insert the following statement to show the variable in the email:

<?php echo $this->escapeHtml($_item->getProduct()->getData('your_attribute')); ?>

tested with M2.3.4

Related Topic