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

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

recent.phtml file used to show recently placed orders, on My Account Dashboard for registred customer with Section Name, Recent Orders at bottom of the page.

recent.phtml file is declared under the customer_account_index.xml file in Sales Module.

  • Using Theme level,
    app/design/frontend/<ThemePackage>/themename/Magento_Sales/templates/order/recent.phtml

    you can see recento order by URL, <SITE_URL>/customer/account

    You need to override customer_account_dashboard_top Block file to change template data,You need to create customer_account_index.xml file to add template,

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

    <?xml version="1.0"?>
    <!--
    /**
     * recent Order layout
     *
     * @author  Rakesh Jesadiya
     * @package Rbj_History
     */
    -->
    <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
        <body>
        	<referenceBlock name="customer_account_dashboard_top" template="Rbj_History::order/recent.phtml" />
        </body>
    </page>

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

    Add Content from Sales Module recent.phtml file to your custom template and start modify based on your requirement.

    Clear a cache and check your login page.