Massimo333 Posted September 21, 2020 Share Posted September 21, 2020 I need to add CSS for the logged in users, but on prestashop in the body of the logged in users there is no particular class to recall them: how can I recall the users logged in on prestashop? P: S I also tried to use the following code to see if I could "catch" logged in users through jQuery, but it doesn't work for me: jQuery('document').ready(function() { if ($this->context->customer->isLogged()) { echo "Logged In"; // Do something here } else { echo "Not Logged In"; // Do something here } }); Link to comment Share on other sites More sharing options...
EvaF Posted September 21, 2020 Share Posted September 21, 2020 don't mess php and javascript code try jQuery('document').ready(function() { {if $logged} console.log("Logged In"); // Do something here - in javascript {else} console.log("Not Logged In"); // Do something here - in javascript {/if} }); Link to comment Share on other sites More sharing options...
Shabab Posted September 21, 2020 Share Posted September 21, 2020 (edited) 26 minutes ago, EvaF said: don't mess php and javascript code try jQuery('document').ready(function() { {if $logged} console.log("Logged In"); // Do something here - in javascript {else} console.log("Not Logged In"); // Do something here - in javascript {/if} }); You need to assign {$logged} to java-script . If you are using separate java-script file then this code did not work . You need to assign {$logged} as java-script variable by using Media::addJsDef('logged', $logged); After that you can use logged as java-script variable jQuery('document').ready(function() { if (logged) { console.log("Logged In"); // Do something here - in javascript } else { console.log("Not Logged In"); // Do something here - in javascript } }); Edited September 21, 2020 by uzishabab (see edit history) Link to comment Share on other sites More sharing options...
Massimo333 Posted September 21, 2020 Author Share Posted September 21, 2020 6 hours ago, EvaF said: don't mess php and javascript code try jQuery('document').ready(function() { {if $logged} console.log("Logged In"); // Do something here - in javascript {else} console.log("Not Logged In"); // Do something here - in javascript {/if} }); Thanks but doesn't work... Link to comment Share on other sites More sharing options...
ZiedDams Posted December 20, 2022 Share Posted December 20, 2022 JS -> if(prestashop.customer.is_logged){ alert("customer is logged in"); }else{ alert("customer is not logged in"); } 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now