Today we discuss about display product image in new order email.
Sometimes you want to add an image of the product in the mail send after a place order.
You will need add some code into this file :-
File : vendor/magento/module-sales/view/frontend/templates/email/items/order/default.phtml
Override 1:-
Override above core file into theme
app/design/frontend/[VENDOR]/[TEMPLATE]/Magento_Sales/templates/email/items/order/default.phtml
Override 2:-
Override above core file into custome module
Yoy have copied vendor/magento/module-sales/view/frontend/layout/sales_email_order_renderers.xml in your module app/code/CompanyName/ModuleName/view/frontend/layout/sales_email_order_renderers.xml
and updated code with below mentioned code :
<?xml version="1.0"?> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd" label="Email Creditmemo Items List" design_abstraction="custom"> <body> <referenceBlock name="sales.email.order.renderers.default"> <action method="setTemplate"> <argument name="template" xsi:type="string">Vendor_Module::email/items/order/default.phtml</argument> </action> </referenceBlock> </body> </page>
OR
<?xml version="1.0"?> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd" label="Email Creditmemo Items List" design_abstraction="custom"> <body> <referenceBlock name="sales.email.order.renderers"> <block class="Magento\Sales\Block\Order\Email\Items\Order\DefaultOrder" as="default" template="Vendor_Module::email/items/order/default.phtml"/> </referenceBlock> </body> </page>
Add product images in transactional Emails sent to customers in Magento 2.
Product image in new order email
override email/items/order/default.phtml in Magento2
Related Post : Magento2 Get Category Image