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,

Path:
app/code/Rbj/History/view/frontend/layout/sales_order_view.xml

Create order_comments.phtml file,
Path:
app/code/Rbj/History/view/frontend/templates/order/order_comments.phtml

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.