How to Override Magento 2 order/items/renderer/default.phtml?

Today, we’re going to teach you guys how to override order/items/renderer/default.phtml in Magento 2.

In order to override the default.phtml file, we need to first create sales_order_item_renderers.xml file in the app/code/MageDelight/Training/view/frontend/layout/ folder and copy the following 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">
    <body>
        <referenceBlock name="sales.order.items.renderers">
            <block class="Magento\Sales\Block\Order\Item\Renderer\DefaultRenderer"
                   name="sales.order.items.renderer.default.configurable" as="configurable"
                   template="MageDelight_Training::order/items/renderer/default.phtml"/>
            <block class="Magento\Sales\Block\Order\Item\Renderer\DefaultRenderer"
                   name="sales.order.items.renderer.default.simple" as="simple"
                   template="MageDelight_Training::order/items/renderer/default.phtml"/>
            <block class="Magento\Downloadable\Block\Sales\Order\Item\Renderer\Downloadable"
                   name="sales.order.items.renderer.downloadable" as="downloadable"
                   template="MageDelight_Training::order/items/renderer/default.phtml"/>
            <block class="Magento\Bundle\Block\Sales\Order\Items\Renderer"
                   name="sales.order.items.renderers.bundle" as="bundle"
                   template="MageDelight_Training::order/items/renderer/bundle/renderer.phtml"/>
            <block class="Magento\GroupedProduct\Block\Order\Item\Renderer\Grouped"
                   name="sales.order.items.renderers.grouped" as="grouped"
                   template="MageDelight_Training::order/items/renderer/default.phtml"/&gt
        </referenceBlock>
    </body>
</page>

After that, we need to replace MageDelight_Training with an actual module name that you want to override.

Lastly, we need to clear the cache and check the output to see if the file is overridden.

Conclusion

And that’s about it!

This is how you can override the default.phtml file in Magento 2.

And if you need our professional assistance, feel free to contact us anytime.

Tags