Magento 2 override order/items/renderer/default.phtml

0
326
Magento 2 override order items renderer default phtml

In this article, you going to see the discussion regarding Magento 2 override order/items/renderer/default.phtml in detail and step by step.

If you are looking for this topic then your are at right place.

Let’s start with the topic of Magento 2 override order/items/renderer/default.phtml

To override default template file use below method.

You have to create layout XML file name as sales_order_item_renderers.xml file in module layout folder section.

Below is path of the layout xml file.

app/code/VendorName/ModuleName/view/frontend/layout/sales_order_item_renderers.xml
<?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="VendorName_ModuleName::order/items/renderer/default.phtml"/>
            <block class="Magento\Sales\Block\Order\Item\Renderer\DefaultRenderer"
                   name="sales.order.items.renderer.default.simple" as="simple"
                   template="VendorName_ModuleName::order/items/renderer/default.phtml"/>
            <block class="Magento\Downloadable\Block\Sales\Order\Item\Renderer\Downloadable"
                   name="sales.order.items.renderer.downloadable" as="downloadable"
                   template="VendorName_ModuleName::order/items/renderer/default.phtml"/>
            <block class="Magento\Bundle\Block\Sales\Order\Items\Renderer"
                   name="sales.order.items.renderers.bundle" as="bundle"
                   template="VendorName_ModuleName::order/items/renderer/bundle/renderer.phtml"/>
            <block class="Magento\GroupedProduct\Block\Order\Item\Renderer\Grouped"
                   name="sales.order.items.renderers.grouped" as="grouped"
                   template="VendorName_ModuleName::order/items/renderer/default.phtml"/>
        </referenceBlock>
    </body>
</page>

In the above layout section change VendorName_ModuleName with your Module name.

After updating the layout file execute the below command to clear cache.

php bin/magento cache:clean
php bin/magento cache:flush

How to Magento 2 override order history file?

Conclusion:

Using above code snippet you can override order items.

I hope you like this article and if you have any query, please comment below.