I'm trying to display a registration pop-up only if a user has never seen it before and it occurred to me it would be wise to also check to make sure they were not already logged in.
But when I follow the suggestions I have seen to use Magento_Customer/js/model/customer, customer ends up being undefined so I can't check customer.isLogged();
Am I missing something?
define([
"jquery",
"Magento_Customer/js/model/customer",
"mage/cookies"
], function ($, customer) {
"use strict";
return function myscript() {
// it was failing setting the variable so I added this
console.log('in myscript', customer);
// the console shows that customer is undefined
var isLoggedIn = customer.isLoggedIn();
var regMsgSeen = $.mage.cookies.get('regMsgSeen');
if(!regMsgSeen && !isLoggedIn) {
$(document).ready(
function () {
$.mage.cookies.set('regMsgSeen',1,{});
setTimeout(
function () {
$('div#zoo-register-form').modal('openModal');
}, 1000);
});
}
}
});