Dipender Singh
Dipender Singh

Reputation: 56

How to check if user is logged in at category page in Opencart

My website category page has product with dropdown filter range 16, 32, 64 and show all. Now I want rest filters including '16 product per page' will works only if user is logged-in otherwise only "16 product per page" is available for not logged in user and they will be redirect to login page for rest filters.

I have checked logged-in and filled the dropdown options like this:

<?php if (!$logged) { ?>
 <!-- My code to fill dropdown option-->            
<?php } else { >
 <!-- By default dropdown option-->
 <?php } ?>

But this is causing an error: "Notice: Undefined variable: logged in"

Upvotes: 1

Views: 3238

Answers (2)

Kunj
Kunj

Reputation: 2018

Add below line in controller > category.php file where you getting the other variable of $category_info.

$this->data['logged'] = $this->customer->isLogged();

Upvotes: 3

Rahul Kaushik
Rahul Kaushik

Reputation: 1464

In Your controller you can do this:

if($this->customer->isLogged()) {
    echo "Customer is logged in and his ID is " . $this->customer->isLogged();
} else {
    echo "Customer is not logged in";
}

Upvotes: 1

Related Questions