Is it possible to call the default welcome message when user is logged in ("Welcome, customer.fullname") in a different .phtml?
I'd need this message in my Magento_Customer/templates/account/customer.phtml
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It only takes a minute to sign up.
Sign up to join this communityIs it possible to call the default welcome message when user is logged in ("Welcome, customer.fullname") in a different .phtml?
I'd need this message in my Magento_Customer/templates/account/customer.phtml
This code is from info.phtml file present at your_project_root/vendor/magento/module-customer/view/frontend/templates/account/dashboard/info.phtml
/** @var \Magento\Customer\Block\Account\Dashboard\Info $block */
?>
<div class="block block-dashboard-info">
<div class="block-title"><strong><?= $block->escapeHtml(__('Account Information')) ?></strong></div>
<div class="block-content">
<div class="box box-information">
<strong class="box-title">
<span><?= $block->escapeHtml(__('Contact Information')) ?></span>
</strong>
<div class="box-content">
<p>
Welcome, <?= $block->escapeHtml($block->getName()) ?><br>
<?= $block->escapeHtml($block->getCustomer()->getEmail()) ?><br>
</p>
<?= $block->getChildHtml('customer.account.dashboard.info.extra'); ?>
</div>
I edited the above code as Welcome, (added) you can check above code, the above phtml file is linked with the block Info as commented in code, and this relation of block and phtml file is defined in the layout file.
Similarly, for your file customer.phtml
you can check the function code in your block or copy the function from Info block or use the additional block of Info also and can solve it.
Please ask me if still you have doubts.