In this post I am going to explain how to get current logged in customer details in PrestaShop 1.7.
1) Inside module or controller file (php)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | if ($this->context->customer->isLogged()) { $customerId = $this->context->customer->id; $firstname = $this->context->customer->firstname; $lastname = $this->context->customer->lastname; $email = $this->context->customer->email; echo $customerId . "<br>"; echo $firstname . "<br>"; echo $lastname . "<br>"; echo $email . "<br>"; // Do something here } else { // Do something here } |
2) Inside template file (tpl)
1 2 3 4 5 6 | {if $customer.is_logged} {$customer.id} {$customer.firstname} {$customer.lastname} {$customer.email} {/if} |
Write an article about ecommerce that help people to grow their ecommerce business. You’ll find best ecommerce guide, news, tips & more!
May 6, 2020 at 12:20 pm
Thank you so much for sharing such a useful information.