Magento – magento1.9 : Check if the customer already exist or not

addtocartcustomermagento-1.9register

How to check whether the customer is already registered user or new user.

If they are a new user the product add to cart logic should be different, If they are a registered user the product add to cart logic should be different.

How to differentiate, and where to edit the login in code?

Best Answer

you can check current users order for new user . if current user has order thats mean he is not new user, otherwise he/she is new user

$customer = Mage::getSingleton('customer/session')->getCustomer();
$email = $customer->getEmail();  
$orderCollection = Mage::getModel(‘sales/order’)->getCollection();
$orderCollection->addFieldToFilter(‘customer_email’, $email);
$newUser =false; 
if(empty(orderCollection->getData()) ){
   $newUser =true; 
}