0

We want to check in the minicart if the customer is loggedin.

<!-- ko if: isCustomerLoggedIn == 1 -->

Does not seem to work well for the mini cart. This only works when you are visually in the checkout. When you are in the category or on the productpage, this does not work.

So how can we always check in the mini cart if the customer is loggedin?

JGeer
  • 1,418
  • 11
  • 59
  • 122

1 Answers1

2
<!-- ko ifnot: isCustomerLoggedIn() -->

<!-- /ko -->

I found it effective in checking customer is login

nhungo duc
  • 193
  • 8
  • Sadly that does not work, we get the JS error: Message: isCustomerLoggedIn is not a function. (In 'isCustomerLoggedIn()', 'isCustomerLoggedIn' is true) – JGeer May 21 '21 at 14:30
  • you can use 'Magento_Customer/js/model/customer' – nhungo duc May 22 '21 at 10:33
  • vendor/magento/module-checkout/view/frontend/web/js/view/form/element/email.js vendor/magento/module-customer/view/frontend/web/js/model/customer.js vendor/magento/module-customer/view/frontend/web/js/customer-data.js . I see magento have some login test case please read through it – nhungo duc May 22 '21 at 10:34
  • https://www.rakeshjesadiya.com/customer-is-logged-in-using-knockout-js-magento-2 – nhungo duc May 22 '21 at 10:40
  • https://magento.stackexchange.com/questions/203951/magento2-check-if-customer-is-logged-in-or-not-in-knockout-template – nhungo duc May 22 '21 at 10:41
  • https://mageprince.com/blog/check-customer-is-logged-in-using-knockout-js-magento-2/ – nhungo duc May 22 '21 at 10:42