How to override order/order_comments.phtml template in Magento 2?

You can override order_comments.phtml file using layout XML by creating a module or directly add template file to the theme level under Magento_Sales module.

order_comments.phtml file used to show the order comment in order details view page.

order_comments.phtml file is declared under the sales_order_view.xml file in Sales Module.

  • Using Theme level,

You can see order comments by URL, <SITE_URL>/sales/order/view/order_id/1/

  • Using Module Level,

You need to create sales_order_view.xml file to add a template,


<?xml version="1.0"?>
 * Order History layout
 * @author  Rakesh Jesadiya
 * @package Rbj_History
<page xmlns:xsi="" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    	<referenceBlock name="order.comments" template="Rbj_History::order/order_comments.phtml" />

Create order_comments.phtml file,

Add Content from Sales Module order_comments.phtml file to your module custom template and modify the template.

Clear a cache and check your login page.