0

On my checkout I need to check first if e-mail exists. If e-mail exists it will show login and password fields with the email field already filled else it will show the registration form.

It's a store to old people who need that everything be simple and easy.

I've tried to use an ajax check inside the phtml form but I'm having problems with loggedin users.

I appreciate any help with that. Thanks.

0

You don't need to check for an email if the user is already logged in, do you? And you can check if the user is logged in by checking his session which is simple done trough:

Mage::getSingleton('customer/session')->isLoggedIn();

If the user is not logged in then you need to use your ajax check (and there's loads of examples how to do it in StackExchange):

$customer = Mage::getModel('customer/customer');
$customer->setWebsiteId(Mage::app()->getWebsite()->getId());
$customer->loadByEmail($customer_email);

if($customer->getId())
{
  "Customer Exist";
}
  • Hi obsergiu, thanks for the response! Yeah, I don't need to check. The issue is that the page loaded behave like the user aren't logged in. – Filipe Marques Dec 28 '18 at 18:00
  • Did you check if your session is working properly? Are you using the session files or database(redis)? You could check using this code: require_once('app/Mage.php'); umask(0); Mage::app('default'); Mage::getSingleton('core/session', array('name'=>'frontend')); if (empty($session)) { $session = Mage::getSingleton("customer/session"); } if ($session->isLoggedIn()) { echo 'worked'; } else echo 'failed'; – obsergiu Dec 29 '18 at 10:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.