0

In template /Magento_Theme/templates/html/header.phtml I need change welcome message for logged users. Now it looks like:

<?php switch ($block->getShowPart()):
case 'welcome': ?>
    <li class="greet welcome" data-bind="scope: 'customer'">
        <!-- ko if: customer().fullname  -->
        <span data-bind="text: new String('<?php echo $block->escapeHtml(__('Welcome, %1!', '%1'));?>').replace('%1', customer().firstname)">
        </span>
        <!-- /ko -->
        <!-- ko ifnot: customer().fullname  -->
        <span></span>
        <!-- /ko -->
    </li>
    <script type="text/x-magento-init">
    {
        "*": {
            "Magento_Ui/js/core/app": {
                "components": {
                    "customer": {
                        "component": "Magento_Customer/js/view/customer"
                    }
                }
            }
        }
    }
    </script>
<?php break; ?>

<?php case 'other': ?>
    <?php echo $block->getChildHtml(); ?>
<?php break; ?>

How I can get customer last name and gender. In the finally I want to have message: Welcome, Man Jon Dough

  • this code not work for me. Have magento 2.2.4 with Ultimo Theme. I get this error: Parse error: syntax error, unexpected end of file, expecting endswitch (T_ENDSWITCH) or case (T_CASE) or default (T_DEFAULT) in /app/design/frontend/Infortis/base/Infortis_Base/templates/html/header.phtml on line 591 Can I help me? many thanks – ignition3d Oct 4 '18 at 14:12
  • If you have a new question, please ask it by clicking the Ask Question button. Include a link to this question if it helps provide context. - From Review – Rama Chandran M Oct 4 '18 at 14:30
  • This does not really answer the question. If you have a different question, you can ask it by clicking Ask Question. You can also add a bounty to draw more attention to this question once you have enough reputation. - From Review – Vivek Kumar Oct 4 '18 at 15:44
0

replace customer().firstname by customer().fullname

0

Edit in <span> whatever you want -

<span data-bind="text: new String('<?php echo $block->escapeHtml(__('Welcome, %1!', '%1'));?>').replace('%1', customer().firstname)">
        </span>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.