Magento 2 – Override Customer Sales Order History Template Not Working

custom-templatelayout-updatemagento2override-block

I want to override sales order history for customer in frontend like this:

app/code/Test/SuccessPage/view/frontend/layout/sales_order_history.xml

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <update handle="customer_account"/>
    <body>
        <referenceContainer name="content">
          <referenceBlock name="sales.order.history.extra.containe">
              <action method="setTemplate">
                  <argument name="template" xsi:type="string">Test_SuccessPage::order/history.phtml
              </action>
          </referenceBlock>
        </referenceContainer>
    </body>
</page>

app/code/Test/SuccessPage/view/frontend/templates/order/history.phtml

<h1> This is a test page </h1>

unfortunately the above code doesnt work at all, it still load the vendor history.phtml

Best Answer

Try following way:


<?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.history">
            <action method="setTemplate">
                <argument name="template" xsi:type="string">Test_SuccessPage::order/history.phtml</argument>
            </action>
        </referenceBlock>
    </body>
</page>