Why does magento register at checkout not working sometimes? How to Auto login already registered customers?
-
16-10-2019 - |
Pergunta
In my magento website, "Guest Checkout" is disabled. People need to register while they checkout. This works fine, as it is a default behaviour. But sometimes, people who register are not really registered, but considered as Guest.
This happens randomly. I don't have any idea what is going wrong. Can anyone help please?
note:
The website uses the default onepage checkout with minor modifications only in templates (jQuery additions for some attractive UI).
the output of running SELECT * FROM customer_group is:
running SELECT * FROM core_config_data WHERE path = 'customer/create_account/default_group' returned empty set.
Solução
At last found the problem, there was a custom modification, which didn't throw an exception, when already registered customer tries to register again. So, that customer was considered as a Guest [NOT LOGGED IN] customer.
The bad part is that, it was straight away done in core files, so I didn't find it until now.
I didn't want to mess up with these changes, so created an event-observer to automatically login, if the customer is already registered.
if(!Mage::helper('customer')->isLoggedIn()){
$data = $evt->getEvent()->getControllerAction()->getRequest()->getPost('billing', array());
$customer = Mage::getModel("customer/customer");
$email = $data['email']; //email entered in billing address section
$customer->setWebsiteId(Mage::app()->getStore()->getWebsiteId())->loadByEmail($email);
if($customer->getId()){
Mage::getSingleton('customer/session')->loginById($customer->getId());
}
}
Outras dicas
You need to clear your cache and reindex the website. Flush all of the caches.