0

The following error is found during the process of upgrading Magento from 2.4.2 to 2.4.4 in console.

Uncaught SyntaxError: Unable to process binding "ifnot: function(){return customer().fullname }"
Message: Unable to parse bindings.
Bindings value: html:

I found out that this error is being caused by this line.

<!-- ko ifnot: customer().fullname  -->
<span class="not-logged-in" data-bind="html: '<?= $escaper->escapeHtmlAttr($welcomeMessage) ?>'"></span>
<?= $block->getBlockHtml('header.additional') ?>
<!-- /ko -->

The full header.phtml file containing this code is below

<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

/**
 * @var \Magento\Theme\Block\Html\Header $block
 * @var \Magento\Framework\Escaper $escaper
 */
$welcomeMessage = $block->getWelcome();
?>
<?php if ($block->getShowPart() == 'welcome') : ?>
    <li class="greet welcome" data-bind="scope: 'customer'">
        <!-- ko if: customer().fullname  -->
        <span class="logged-in"
              data-bind="text: new String('<?= $escaper->escapeHtml(__('Welcome, %1!', '%1')) ?>').replace('%1', customer().fullname)">
        </span>
        <!-- /ko -->
        <!-- ko ifnot: customer().fullname  -->
        <span class="not-logged-in" data-bind="html: '<?= $escaper->escapeHtmlAttr($welcomeMessage) ?>'"></span>
        <?= $block->getBlockHtml('header.additional') ?>
        <!-- /ko -->
    </li>
    <script type="text/x-magento-init">
    {
        "*": {
            "Magento_Ui/js/core/app": {
                "components": {
                    "customer": {
                        "component": "Magento_Customer/js/view/customer"
                    }
                }
            }
        }
    }
    </script>
<?php elseif ($block->getShowPart() == 'other') :?>
    <?= $block->getChildHtml() ?>
<?php endif ?>
3
  • Look like your code is fine but not sure why you are facing an error. This is core code in header.phtml file as well. Jul 28, 2022 at 9:56
  • Yes, also I verified the contents of the file with those of the file header.phtml in the live site. I'm getting this error on the staging site. Everything looks identical. Please pay a deeper look into this issue to help me. Jul 28, 2022 at 10:09
  • @RakeshJesadiya, this one is fixed. I got another error in the product page. Kindly have a look at it please. magento.stackexchange.com/questions/358362/… Jul 29, 2022 at 3:18

1 Answer 1

0

Ensure you check if the customer is logged in before you process the logic that requests the customer information.

This answer might be helpful to implement it: https://magento.stackexchange.com/a/203955/16416

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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