Prestashop 1.7 – Get current logged in customer details

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)

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)

{if $customer.is_logged}
    {$customer.id}
    {$customer.firstname}
    {$customer.lastname}
    {$customer.email}
{/if}

 

1 Comment

  1. Thank you so much for sharing such a useful information.

Leave a Reply

Your email address will not be published. Required fields are marked *