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 ?>

Sumit
  • 4,875
  • 2
  • 19
  • 35
CodeForGood
  • 764
  • 7
  • 31
  • 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. – Rakesh Jesadiya Jul 28 '22 at 09: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. – CodeForGood Jul 28 '22 at 10:09
  • @RakeshJesadiya, this one is fixed. I got another error in the product page. Kindly have a look at it please. https://magento.stackexchange.com/questions/358362/magento-2-4-4-uncaught-typeerror-cannot-read-properties-of-undefined-reading – CodeForGood Jul 29 '22 at 03:18

1 Answers1

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

Rafael Corrêa Gomes
  • 13,309
  • 14
  • 84
  • 171