By default when a customer check out as a register user magento will store the customer info and link the customer to existing order using:
Table : sales_flat_order
- customer_id : numeric customer id
- customer_is_guest : bool - add clickable link in sales order admin
Therefore you could create a custom module. Then using an observer you could
- Check if the customer is checking out as guest
- If there is a existing customer with the same email
- Update the order accordingly.
Please note this method may assign the order to wrong user if someone existing customer mistype there email
Take a look at Magento - Wiki - Customize Magento using Event/Observer
In config.xml
...
<events>
<sales_order_place_before>
<observers>
<sales_order_place_after_observer>
<type>singleton</type>
<class>convertcustomer/observer</class>
<method>checkCustomerRecord</method>
</sales_order_place_after_observer>
</observers>
</sales_order_place_before>
</events>
...
In observer.php
Class MagePal_Model_ConvertCustomer_Observer{
function checkCustomerRecord($observer){
$order = $observer->getOrder();
// if guest
if(!$order->getCustomerId()){
$storeId = $order->getStoreId()
$websiteId = Mage::getModel('core/store')->load($storeId)->getWebsiteId();
$customer = Mage::getModel("customer/customer");
$customer->setWebsiteId($websiteId);
$customer->loadByEmail($email);
//if email found
if($customer->getId()){
$order->setCustomerId($customer->getId());
$order->setCustomerIsGuest(0);
}
}
}
}