How to change the lable in header section after login and before login in magneto2?

In my acount.phtml file we made some changes then override the file from this path to our custom module magneto_theme.

/var/www/html/Szco_Supplies_netsuite/vendor/swissup/theme-frontend-argento-blank/Magento_Theme/templates/html/header/my-account.phtml

<?php if (!$topLinks = $this->getLayout()->getBlock('top.links')) return; ?>
<div class="switcher customer switcher-customer" data-ui-id="customer-switcher" id="switcher-customer">
    <?php
    $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
    $customerSession = $objectManager->get('Magento\Customer\Model\Session');
    ?>

    <?php if ($customerSession->isLoggedIn()): ?>
        <strong class="label switcher-label"><span><?= $block->escapeHtml(__('My Account')) ?></span></strong>
        <div class="actions dropdown options switcher-options">
            <div class="action toggle switcher-trigger"
                 id="switcher-customer-trigger"
                 data-mage-init='{"dropdown":{}}'
                 data-toggle="dropdown"
                 data-trigger-keypress-button="true">
                <a class="link"
                   href="<?= $block->escapeUrl($this->getUrl('customer/account')) ?>"
                   title="<?= $block->escapeHtml(__('My Account')) ?>">
                    <i class="icon"></i>
                    <span class="text"><?= $block->escapeHtml(__('My Account')) ?></span>
                </a>
            </div>
            <div>
                <?= $topLinks->setCssClass('dropdown switcher-dropdown')->toHtml(); ?>
            </div>
        </div>
    <?php else: ?>
        <strong class="label switcher-label"><span class="login-link"><?= $block->escapeHtml(__('Log In')) ?></span></strong>
        <div class="actions switcher-options">
            <a class="link"
               href="<?= $block->escapeUrl($this->getUrl('customer/account')) ?>"
               title="<?= $block->escapeHtml(__('Log In')) ?>">
                <i class="icon"></i>
                <span class="text"><?= $block->escapeHtml(__('Log In')) ?></span>
            </a>
        </div>
    <?php endif; ?>

</div>

Leave a comment

Your email address will not be published. Required fields are marked *