jose-c
7/27/2018 - 3:34 PM

client-logged-javascript

Chekear si un cliente esta logueado

define(
    [
        'jquery',
        'Magento_Customer/js/customer-data',
    ],
    function($,customer){
        'use strict';

        var appVolarSite = function () {

        };
        appVolarSite.prototype = {
            selectors : {
                menuUser : '.panel.header ul.header.links:first'
            },
            init: function () {
                var self = this;
                self.showHideLinksCustomer();
            },
            showHideLinksCustomer:function () {
                var self = this;
                var time = setInterval(function () {
                    if (localStorage["mage-cache-storage"] != '{}') {
                        clearInterval(time);
                    }
                    var customerData = customer.get('customer');
                    if (typeof customerData().fullname !== 'undefined') {
                        $(self.selectors.menuUser).css({
                            display:'block'
                        });
                    }
                }, 1000);
            }
        };

        $(document).ready(function(){
            var app = new appVolarSite();
            app.init();
        });
});