Magento 2 override default.phtml and items.phtml in new order email

Magento 2 override default.phtml and items.phtml in new order email

August 10, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento 2 override default.phtml and items.phtml in new order email

Overriding Default and Items PHTML Files in Magento 2 New Order Email Templates

As a developer focusing on e-commerce platforms like Magento 2, we often need to customize default templates to fit specific business needs. In this guide, we’ll delve into how to override both the default.phtml and items.phtml files used in the new order email templates.

Understanding the Default Override Process

You’ve already successfully overridden the default.phtml file using a custom module and layout XML configuration:

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceBlock name="sales.email.order.renderers">
            <block class="Magento\Sales\Block\Order\Email\Items\Order\DefaultOrder" as="default" template="EmizenTech_SalesEmail::email/items/order/default.phtml"/>
        </referenceBlock>
    </body>
</page>

This XML file, sales_email_orders_renderers.xml, tells Magento to replace the default default.phtml template with your custom version located at app/code/EmizenTech/SalesEmail/view/frontend/templates/email/items/order/default.phtml.

Overriding Multiple Templates in a Single XML File

Now let’s explore how to override multiple templates using the same XML file. To include both the default and items templates, we can update our existing XML as follows:

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceBlock name="sales.email.order.renderers">
            <block class="Magento\Sales\Block\Order\Email\Items\Order\DefaultOrder" as="default" template="EmizenTech_SalesEmail::email/items/order/default.phtml"/>
            <block class="Magento\Sales\Block\Order\Email\Items\Order\Items" as="items" template="EmizenTech_SalesEmail::email/items/item.phtml"/>
        </referenceBlock>
    </body>
</page>

In this updated version, we’ve added a new block for the items template. This allows you to override both the default and items templates in a single XML file.

Locating the Items Template

To find the original items.phtml template:

  1. Navigate to the Magento 2 core: /vendor/magento/module-sales/view/frontend/templates/email/
  2. The items.phtml file is located directly under this directory.

Now, let’s discuss how to create your custom version of this file.

Creating Your Custom Items Template

To create a custom items.phtml template:

  1. In your module (in our example: EmizenTech/SalesEmail), navigate to the view frontend directory.
  2. Create a folder structure that mirrors Magento 2’s core: /view/frontend/templates/email/
  3. Inside this new folder, add a new file named item.phtml.

Your custom template should reside at: /app/code/EmizenTech/SalesEmail/view/frontend/templates/email/item.phtml

Conclusion

By following the steps outlined in this comprehensive guide, you can successfully override both the default and items PHTML files used in Magento 2’s new order email templates. This allows for greater customization and flexibility to meet your specific business requirements.

Remember, when working with core templates, always follow best practices such as localizing your changes using a custom module or theme to ensure the integrity of your code remains intact during future updates.

For more advanced techniques in Magento 2 template overriding and customization, consider exploring our [in-depth tutorials][laravelcompany-magento-2-development] at LaravelCompany.com.

Magento 2 Extensions Themes Configuration

Our network