Home > Mobile >  Change My Orders Title in Account Dashboard
Change My Orders Title in Account Dashboard

Time:01-13

I have changed the "My Orders" link/tab to "My Web Orders" on the left hand side by using this code

<referenceBlock name="customer-account-navigation-orders-link">
        <arguments>
            <argument name="label" xsi:type="string" translate="true">My Web Orders</argument>
        </arguments>
    </referenceBlock>

But how the actual page main title hasn't changed, so how do i change that? enter image description here

CodePudding user response:

Step 1:Create etc/registration.php file

<?php
\Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::MODULE,
    'Sunarc_Custom',
    __DIR__
);

Step 2:Create the etc/module.xml file.

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="Sunarc_Custom" setup_version="1.0.0">
        <sequence>
            <module name="Magento_Backend"/>
        </sequence>
    </module>
</config>

Step 3:- Create etc/di.xml file.

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <preference for="Magento\Sales\Controller\Order\History" type="Sunarc\Custom\Controller\Order\History" />
</config>

Step 4:- Override \Magento\Sales\Controller\Order\History.php with your custom Sunarc\Custom\Controller\Order\History.php file

<?php

namespace Sunarc\Custom\Controller\Order;

class History extends \Magento\Sales\Controller\Order\History
{
    /**
     * @return \Magento\Framework\Controller\Result\Redirect|\Magento\Framework\View\Result\Page
     */
    public function execute()
    {
       /** @var \Magento\Framework\View\Result\Page $resultPage */
       $resultPage = $this->resultPageFactory->create();
       $resultPage->getConfig()->getTitle()->set(__('My Web Orders'));
       return $resultPage;
    }
}

Result

CodePudding user response:

you can also change the title of the "My Orders" section in the account dashboard by using a translation file. The translation file can be found in the following location:

app/design/frontend/[Vendor]/[Theme]/i18n/en_US.csv

You can change the title by adding a new row in the file with the key value "My Orders" and the new title in the translation column.

Example : My Orders, My Web Orders,
  • Related