For orders where the user was a guest the field customer_is_guest
on the table sales_flat_order
will be 1
. Whereas for registered user this will have a value of 0
.
For the guest orders it's easy.
$order->Mage::getModel('sales/order')->load($id);
$isGuest = $order->getCustomerIsGuest();
//or
//$isGuest = $order->getCustomerId() == 0;
But to check if the customer registered or it was already logged in is not that easy.
You cannot get the information from the order object. You need to check the quote object associated to the order. But that may not exist.
You can try something like this:
$order->Mage::getModel('sales/order')->load($id);
if ($order->getCustomerIsGuest()) {
//customer is guest
}
else {
$quote = Mage::getModel('sales/quote')->load($order->getQuoteId());
if ($quote->getId()) {
$method = $quote->getCheckoutMethod();
if ($method == 'register'){
//customer registered when placing the order
}
else {
//customer was already logged in when placing the order
}
}
else {
// there is no way of knowing if the customer registered or was already logged in but for sure an account exists.
}
}